AddEventAliasesPass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\EventDispatcher\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. /**
  14. * This pass allows bundles to extend the list of event aliases.
  15. *
  16. * @author Alexander M. Turek <me@derrabus.de>
  17. */
  18. class AddEventAliasesPass implements CompilerPassInterface
  19. {
  20. public function __construct(
  21. private array $eventAliases,
  22. ) {
  23. }
  24. public function process(ContainerBuilder $container): void
  25. {
  26. $eventAliases = $container->hasParameter('event_dispatcher.event_aliases') ? $container->getParameter('event_dispatcher.event_aliases') : [];
  27. $container->setParameter(
  28. 'event_dispatcher.event_aliases',
  29. array_merge($eventAliases, $this->eventAliases)
  30. );
  31. }
  32. }