1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-24 18:41:52 +02:00
Files
php-phpbb/phpBB/phpbb/di/pass/convert_events.php
Marc Alexander 66b54d4469 [ticket/17176] Use Symfony name for event dispatcher
The previously used override of the names is no longer supported.

PHPBB3-17176
2023-09-18 19:28:18 +02:00

52 lines
1.3 KiB
PHP

<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\di\pass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Converts event types to Symfony ones
*/
class convert_events implements CompilerPassInterface
{
/** @var string[] Map for conversions of types */
private static array $conversions = [
'event.listener_listener' => 'kernel.event_listener',
'event.listener' => 'kernel.event_subscriber',
];
/**
* Modify the container before it is passed to the rest of the code
* Add Symfony event tags to previously used phpBB ones
*
* @param ContainerBuilder $container ContainerBuilder object
* @return void
*/
public function process(ContainerBuilder $container): void
{
// Add alias for event dispatcher
$container->addAliases(['dispatcher' => 'event_dispatcher']);
foreach (self::$conversions as $from => $to)
{
foreach ($container->findTaggedServiceIds($from, true) as $id => $tags)
{
$definition = $container->getDefinition($id);
$definition->addTag($to);
}
}
}
}