mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #1076 from naderman/ticket/11193
[ticket/11193] Instantiate a single collection_pass for all collections
This commit is contained in:
commit
05380c8d0e
5 changed files with 17 additions and 16 deletions
|
@ -94,7 +94,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug(
|
||||||
new phpbb_di_extension_core($phpbb_root_path),
|
new phpbb_di_extension_core($phpbb_root_path),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'),
|
new phpbb_di_pass_collection_pass(),
|
||||||
),
|
),
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx
|
$phpEx
|
||||||
|
|
|
@ -48,6 +48,8 @@ services:
|
||||||
class: phpbb_di_service_collection
|
class: phpbb_di_service_collection
|
||||||
arguments:
|
arguments:
|
||||||
- @service_container
|
- @service_container
|
||||||
|
tags:
|
||||||
|
- { name: service_collection, tag: cron.task }
|
||||||
|
|
||||||
cron.manager:
|
cron.manager:
|
||||||
class: phpbb_cron_manager
|
class: phpbb_cron_manager
|
||||||
|
|
|
@ -65,7 +65,7 @@ if (isset($_GET['avatar']))
|
||||||
new phpbb_di_extension_core($phpbb_root_path),
|
new phpbb_di_extension_core($phpbb_root_path),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'),
|
new phpbb_di_pass_collection_pass(),
|
||||||
),
|
),
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx
|
$phpEx
|
||||||
|
|
|
@ -18,17 +18,13 @@ if (!defined('IN_PHPBB'))
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
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
|
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
|
* 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)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$definition = $container->getDefinition($this->collection_service);
|
foreach ($container->findTaggedServiceIds('service_collection') as $id => $data)
|
||||||
|
|
||||||
foreach ($container->findTaggedServiceIds($this->service_tag) 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug(
|
||||||
new phpbb_di_extension_core($phpbb_root_path),
|
new phpbb_di_extension_core($phpbb_root_path),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'),
|
new phpbb_di_pass_collection_pass(),
|
||||||
),
|
),
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx
|
$phpEx
|
||||||
|
|
Loading…
Add table
Reference in a new issue