diff options
author | Igor Wiedler <igor@wiedler.ch> | 2012-11-11 10:05:06 -0800 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-11-11 10:05:06 -0800 |
commit | 05380c8d0efae9f57c9c2f0c3b59f6593dc4e180 (patch) | |
tree | b4d9b386dbf57ba59486043f1838edd49cb2d621 /phpBB | |
parent | 69845585a2bc6720e6c512227f436782c7bf5d29 (diff) | |
parent | d2a051cdd4269fd5749bdd4e7619fc5176a510a8 (diff) | |
download | forums-05380c8d0efae9f57c9c2f0c3b59f6593dc4e180.tar forums-05380c8d0efae9f57c9c2f0c3b59f6593dc4e180.tar.gz forums-05380c8d0efae9f57c9c2f0c3b59f6593dc4e180.tar.bz2 forums-05380c8d0efae9f57c9c2f0c3b59f6593dc4e180.tar.xz forums-05380c8d0efae9f57c9c2f0c3b59f6593dc4e180.zip |
Merge pull request #1076 from naderman/ticket/11193
[ticket/11193] Instantiate a single collection_pass for all collections
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/common.php | 2 | ||||
-rw-r--r-- | phpBB/config/services.yml | 2 | ||||
-rw-r--r-- | phpBB/download/file.php | 2 | ||||
-rw-r--r-- | phpBB/includes/di/pass/collection_pass.php | 25 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 2 |
5 files changed, 17 insertions, 16 deletions
diff --git a/phpBB/common.php b/phpBB/common.php index 002d435b6e..c4237dfcf5 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -94,7 +94,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 42bb473e66..20aa0546d5 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -48,6 +48,8 @@ services: class: phpbb_di_service_collection arguments: - @service_container + tags: + - { name: service_collection, tag: cron.task } cron.manager: class: phpbb_cron_manager diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 95b20a88d2..79f53245b9 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -65,7 +65,7 @@ if (isset($_GET['avatar'])) new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx diff --git a/phpBB/includes/di/pass/collection_pass.php b/phpBB/includes/di/pass/collection_pass.php index 70a44d1d51..d5b82f61da 100644 --- a/phpBB/includes/di/pass/collection_pass.php +++ b/phpBB/includes/di/pass/collection_pass.php @@ -18,17 +18,13 @@ if (!defined('IN_PHPBB')) use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +/** +* Appends an add method call to the definition of each collection service for +* the services tagged with the appropriate name defined in the collection's +* service_collection tag. +*/ class phpbb_di_pass_collection_pass implements CompilerPassInterface { - private $collection_service; - private $service_tag; - - public function __construct($collection_service, $service_tag) - { - $this->collection_service = $collection_service; - $this->service_tag = $service_tag; - } - /** * Modify the container before it is passed to the rest of the code * @@ -37,11 +33,14 @@ class phpbb_di_pass_collection_pass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - $definition = $container->getDefinition($this->collection_service); - - foreach ($container->findTaggedServiceIds($this->service_tag) as $id => $data) + foreach ($container->findTaggedServiceIds('service_collection') as $id => $data) { - $definition->addMethodCall('add', array($id)); + $definition = $container->getDefinition($id); + + foreach ($container->findTaggedServiceIds($data['tag']) as $service_id => $service_data) + { + $definition->addMethodCall('add', array($service_id)); + } } } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 27cc4951a9..297802c210 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -112,7 +112,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx |