phpBB

Code Changes

File: phpbb/cron/manager.php

  Unmodified   Added   Modified   Removed
Line 15Line 15

use phpbb\cron\task\wrapper;
use phpbb\routing\helper;


use phpbb\cron\task\wrapper;
use phpbb\routing\helper;

 
use Symfony\Component\DependencyInjection\ContainerInterface;


/**
* Cron manager class.


/**
* Cron manager class.

Line 23Line 24
*/
class manager
{

*/
class manager
{

 
	/**
* @var ContainerInterface
*/
protected $phpbb_container;


	/**
* @var helper
*/

	/**
* @var helper
*/

Line 34Line 40
	*
* @var array
*/

	*
* @var array
*/

	protected $tasks = array();








	protected $tasks = [];

/**
* Flag indicating if $this->tasks contains tasks registered in the container
*
* @var bool
*/
protected $is_initialised_from_container = false;


/**
* @var string


/**
* @var string

Line 49Line 62
	/**
* Constructor. Loads all available tasks.
*

	/**
* Constructor. Loads all available tasks.
*

	* @param array|\Traversable $tasks Provides an iterable set of task names

	* @param ContainerInterface $phpbb_container Container

	* @param helper $routing_helper Routing helper
* @param string $phpbb_root_path Relative path to phpBB root
* @param string $php_ext PHP file extension
*/

	* @param helper $routing_helper Routing helper
* @param string $phpbb_root_path Relative path to phpBB root
* @param string $php_ext PHP file extension
*/

	public function __construct($tasks, helper $routing_helper, $phpbb_root_path, $php_ext)

	public function __construct(ContainerInterface $phpbb_container, helper $routing_helper, $phpbb_root_path, $php_ext)

	{

	{

 
		$this->phpbb_container = $phpbb_container;

		$this->routing_helper = $routing_helper;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

		$this->routing_helper = $routing_helper;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;


$this->load_tasks($tasks);

 
	}

/**

	}

/**

Line 76Line 88
		foreach ($tasks as $task)
{
$this->tasks[] = $this->wrap_task($task);

		foreach ($tasks as $task)
{
$this->tasks[] = $this->wrap_task($task);

 
		}
}

/**
* Loads registered tasks from the container, wraps them
* and puts them into $this->tasks.
*
* @return null
*/
public function load_tasks_from_container()
{
if (!$this->is_initialised_from_container)
{
$this->is_initialised_from_container = true;

$tasks = $this->phpbb_container->get('cron.task_collection');

$this->load_tasks($tasks);

		}
}


		}
}


Line 90Line 120
	*/
public function find_one_ready_task()
{

	*/
public function find_one_ready_task()
{

 
		$this->load_tasks_from_container();


		shuffle($this->tasks);
foreach ($this->tasks as $task)
{

		shuffle($this->tasks);
foreach ($this->tasks as $task)
{

Line 108Line 140
	*/
public function find_all_ready_tasks()
{

	*/
public function find_all_ready_tasks()
{

		$tasks = array();



		$this->load_tasks_from_container();

$tasks = [];

		foreach ($this->tasks as $task)
{
if ($task->is_ready())

		foreach ($this->tasks as $task)
{
if ($task->is_ready())

Line 131Line 165
	*/
public function find_task($name)
{

	*/
public function find_task($name)
{

 
		$this->load_tasks_from_container();


		foreach ($this->tasks as $task)
{
if ($task->get_name() == $name)

		foreach ($this->tasks as $task)
{
if ($task->get_name() == $name)

Line 148Line 184
	*/
public function get_tasks()
{

	*/
public function get_tasks()
{

 
		$this->load_tasks_from_container();


		return $this->tasks;
}


		return $this->tasks;
}