EventDispatcher.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Symfony\Framework;
  3. use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher;
  4. use Symfony\Component\EventDispatcher\Event;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. /*
  7. * This file is part of the Symfony package.
  8. *
  9. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. /**
  15. * This EventDispatcher implementation uses a DependencyInjection container to load listeners.
  16. *
  17. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  18. */
  19. class EventDispatcher extends BaseEventDispatcher
  20. {
  21. public function setContainer(ContainerInterface $container)
  22. {
  23. foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $attributes) {
  24. $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
  25. $container->get($id)->register($this, $priority);
  26. }
  27. }
  28. }