mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-16 05:34:01 +02:00
[ticket/13740] Fix itteration problems, implement class name aware collections
PHPBB3-13740
This commit is contained in:
@@ -34,10 +34,12 @@ class collection_pass implements CompilerPassInterface
|
||||
foreach ($container->findTaggedServiceIds('service_collection') as $id => $data)
|
||||
{
|
||||
$definition = $container->getDefinition($id);
|
||||
$is_ordered_collection = (substr($definition->getClass(), -strlen('ordered_service_collection')) === 'ordered_service_collection');
|
||||
$is_class_name_aware = (isset($data[0]['class_name_aware']) && $data[0]['class_name_aware']);
|
||||
|
||||
foreach ($container->findTaggedServiceIds($data[0]['tag']) as $service_id => $service_data)
|
||||
{
|
||||
if (substr($definition->getClass(), -strlen('ordered_service_collection')) === 'ordered_service_collection')
|
||||
if ($is_ordered_collection)
|
||||
{
|
||||
$arguments = array($service_id, $service_data[0]['order']);
|
||||
}
|
||||
@@ -46,6 +48,15 @@ class collection_pass implements CompilerPassInterface
|
||||
$arguments = array($service_id);
|
||||
}
|
||||
|
||||
if ($is_class_name_aware)
|
||||
{
|
||||
$service_definition = $container->getDefinition($service_id);
|
||||
$definition->addMethodCall('add_service_class', array(
|
||||
$service_id,
|
||||
$service_definition->getClass()
|
||||
));
|
||||
}
|
||||
|
||||
$definition->addMethodCall('add', $arguments);
|
||||
}
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ class service_collection extends \ArrayObject
|
||||
* @param string $service_id
|
||||
* @param string $class
|
||||
*/
|
||||
public function add_service_classes($service_id, $class)
|
||||
public function add_service_class($service_id, $class)
|
||||
{
|
||||
$this->service_classes[$service_id] = $class;
|
||||
}
|
||||
|
Reference in New Issue
Block a user