aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/config/services.yml10
-rw-r--r--phpBB/includes/cron/task/collection.php51
-rw-r--r--phpBB/includes/cron/task/provider.php66
-rw-r--r--phpBB/includes/di/pass/cron.php2
4 files changed, 18 insertions, 111 deletions
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index b77c3d6c3f..b1aaf1660d 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -44,19 +44,15 @@ services:
- @cache.driver
- %tables.config%
- cron.task_provider:
- class: phpbb_cron_task_provider
- arguments:
- - @cron.task_collection
- - @service_container
-
cron.task_collection:
class: phpbb_cron_task_collection
+ arguments:
+ - @service_container
cron.manager:
class: phpbb_cron_manager
arguments:
- - @cron.task_provider
+ - @cron.task_collection
- %core.root_path%
- %core.php_ext%
diff --git a/phpBB/includes/cron/task/collection.php b/phpBB/includes/cron/task/collection.php
index d05be9012c..84607dc28d 100644
--- a/phpBB/includes/cron/task/collection.php
+++ b/phpBB/includes/cron/task/collection.php
@@ -15,58 +15,35 @@ if (!defined('IN_PHPBB'))
exit;
}
+use Symfony\Component\DependencyInjection\TaggedContainerInterface;
+
/**
* Collects cron tasks
*
* @package phpBB3
*/
-class phpbb_cron_task_collection implements ArrayAccess
+class phpbb_cron_task_collection extends ArrayObject
{
/**
- * ArrayAccess method
- *
- * @param mixed $offset Array offset
- */
- public function offsetExists($offset)
- {
- return isset($this->tasks[$offset]);
- }
-
- /**
- * ArrayAccess method
- *
- * @param mixed $offset Array offset
- */
- public function offsetGet($offset)
- {
- return $this->offsetExists($offset) ? $this->tasks[$offset] : null;
- }
-
- /**
- * ArrayAccess method
+ * Constructor
*
- * @param mixed $offset Array offset
- * @param mixed $value New value
+ * @param TaggedContainerInterface $container Container object
*/
- public function offsetSet($offset, $value)
+ public function __construct(TaggedContainerInterface $container)
{
- if ($offset === null)
- {
- $this->tasks[] = $value;
- }
- else
- {
- $this->tasks[$offset] = $value;
- }
+ $this->container = $container;
}
/**
- * ArrayAccess method
+ * Add a cron task to the collection
*
- * @param mixed $offset Array offset
+ * @param string $name The service name of the cron task
+ * @return null
*/
- public function offsetUnset($offset)
+ public function add($name)
{
- $this->tasks[$offset] = null;
+ $task = $this->container->get($name);
+ $task->set_name($name);
+ $this->offsetSet($name, $task);
}
}
diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php
deleted file mode 100644
index 08e54a651a..0000000000
--- a/phpBB/includes/cron/task/provider.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
-*
-* @package phpBB3
-* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-use Symfony\Component\DependencyInjection\TaggedContainerInterface;
-
-/**
-* Provides cron manager with tasks
-*
-* Finds installed cron tasks and makes them available to the cron manager.
-*
-* @package phpBB3
-*/
-class phpbb_cron_task_provider implements IteratorAggregate
-{
- private $tasks;
-
- public function __construct(phpbb_cron_task_collection $tasks, TaggedContainerInterface $container)
- {
- $this->tasks = $tasks;
- $this->container = $container;
- }
-
- /**
- * Retrieve an iterator over all items
- *
- * @return ArrayIterator An iterator for the array of cron tasks
- */
- public function getIterator()
- {
- $tasks = array();
- foreach ($this->tasks as $names)
- {
- foreach ($names as $name)
- {
- if (!$this->container->has($name))
- {
- continue;
- }
-
- $task = $this->container->get($name);
- if ($task instanceof phpbb_cron_task_base)
- {
- $task->set_name($name);
- }
-
- $tasks[] = $task;
- }
- }
-
- return new ArrayIterator($tasks);
- }
-}
diff --git a/phpBB/includes/di/pass/cron.php b/phpBB/includes/di/pass/cron.php
index b5fc4af9fc..53fe0a61c8 100644
--- a/phpBB/includes/di/pass/cron.php
+++ b/phpBB/includes/di/pass/cron.php
@@ -32,7 +32,7 @@ class phpbb_di_pass_cron implements CompilerPassInterface
foreach ($container->findTaggedServiceIds('cron.task') as $id => $data)
{
- $definition->addMethodCall('offsetSet', array(null, $id));
+ $definition->addMethodCall('add', array($id));
}
}
}