Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

manager.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 2.95 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\cron;
015   
016  /**
017  * Cron manager class.
018  *
019  * Finds installed cron tasks, stores task objects, provides task selection.
020  */
021  class manager
022  {
023      /**
024      * Set of \phpbb\cron\task\wrapper objects.
025      * Array holding all tasks that have been found.
026      *
027      * @var array
028      */
029      protected $tasks = array();
030   
031      protected $phpbb_root_path;
032      protected $php_ext;
033   
034      /**
035      * Constructor. Loads all available tasks.
036      *
037      * @param array|\Traversable $tasks Provides an iterable set of task names
038      * @param string $phpbb_root_path Relative path to phpBB root
039      * @param string $php_ext PHP file extension
040      */
041      public function __construct($tasks, $phpbb_root_path, $php_ext)
042      {
043          $this->phpbb_root_path = $phpbb_root_path;
044          $this->php_ext = $php_ext;
045   
046          $this->load_tasks($tasks);
047      }
048   
049      /**
050      * Loads tasks given by name, wraps them
051      * and puts them into $this->tasks.
052      *
053      * @param array|\Traversable $tasks        Array of instances of \phpbb\cron\task\task
054      *
055      * @return null
056      */
057      public function load_tasks($tasks)
058      {
059          foreach ($tasks as $task)
060          {
061              $this->tasks[] = $this->wrap_task($task);
062          }
063      }
064   
065      /**
066      * Finds a task that is ready to run.
067      *
068      * If several tasks are ready, any one of them could be returned.
069      *
070      * If no tasks are ready, null is returned.
071      *
072      * @return \phpbb\cron\task\wrapper|null
073      */
074      public function find_one_ready_task()
075      {
076          shuffle($this->tasks);
077          foreach ($this->tasks as $task)
078          {
079              if ($task->is_ready())
080              {
081                  return $task;
082              }
083          }
084          return null;
085      }
086   
087      /**
088      * Finds all tasks that are ready to run.
089      *
090      * @return array        List of tasks which are ready to run (wrapped in \phpbb\cron\task\wrapper).
091      */
092      public function find_all_ready_tasks()
093      {
094          $tasks = array();
095          foreach ($this->tasks as $task)
096          {
097              if ($task->is_ready())
098              {
099                  $tasks[] = $task;
100              }
101          }
102          return $tasks;
103      }
104   
105      /**
106      * Finds a task by name.
107      *
108      * If there is no task with the specified name, null is returned.
109      *
110      * Web runner uses this method to resolve names to tasks.
111      *
112      * @param string                $name Name of the task to look up.
113      * @return \phpbb\cron\task\wrapper    A wrapped task corresponding to the given name, or null.
114      */
115      public function find_task($name)
116      {
117          foreach ($this->tasks as $task)
118          {
119              if ($task->get_name() == $name)
120              {
121                  return $task;
122              }
123          }
124          return null;
125      }
126   
127      /**
128      * Find all tasks and return them.
129      *
130      * @return array List of all tasks.
131      */
132      public function get_tasks()
133      {
134          return $this->tasks;
135      }
136   
137      /**
138      * Wraps a task inside an instance of \phpbb\cron\task\wrapper.
139      *
140      * @param  \phpbb\cron\task\task             $task The task.
141      * @return \phpbb\cron\task\wrapper    The wrapped task.
142      */
143      public function wrap_task(\phpbb\cron\task\task $task)
144      {
145          return new \phpbb\cron\task\wrapper($task, $this->phpbb_root_path, $this->php_ext);
146      }
147  }
148