diff options
Diffstat (limited to 'phpBB/includes/cron/task/provider.php')
| -rw-r--r-- | phpBB/includes/cron/task/provider.php | 43 | 
1 files changed, 27 insertions, 16 deletions
| diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index 1482051699..134723ebd1 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))  	exit;  } +use Symfony\Component\DependencyInjection\TaggedContainerInterface; +  /**  * Provides cron manager with tasks  * @@ -22,27 +24,36 @@ if (!defined('IN_PHPBB'))  *  * @package phpBB3  */ -class phpbb_cron_task_provider extends phpbb_extension_provider +class phpbb_cron_task_provider implements IteratorAggregate  { +	private $container; + +	public function __construct(TaggedContainerInterface $container) +	{ +		$this->container = $container; +	} +  	/** -	* Finds cron task names using the extension manager. -	* -	* All PHP files in includes/cron/task/core/ are considered tasks. Tasks -	* in extensions have to be located in a directory called cron or a subdir -	* of a directory called cron. The class and filename must end in a _task -	* suffix. Additionally all PHP files in includes/cron/task/core/ are -	* tasks. +	* Retrieve an iterator over all items  	* -	* @return array     List of task names +	* @return ArrayIterator An iterator for the array of cron tasks  	*/ -	protected function find() +	public function getIterator()  	{ -		$finder = $this->extension_manager->get_finder(); +		$definitions = $this->container->findTaggedServiceIds('cron.task'); + +		$tasks = array(); +		foreach ($definitions as $name => $definition) +		{ +			$task = $this->container->get($name); +			if ($task instanceof phpbb_cron_task_base) +			{ +				$task->set_name($name); +			} + +			$tasks[] = $task; +		} -		return $finder -			->extension_suffix('_task') -			->extension_directory('/cron') -			->core_path('includes/cron/task/core/') -			->get_classes(); +		return new ArrayIterator($tasks);  	}  } | 
