Aucune description

LegacyEventProxy.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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;
  11. use Psr\EventDispatcher\StoppableEventInterface;
  12. use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;
  13. /**
  14. * @internal to be removed in 5.0.
  15. */
  16. final class LegacyEventProxy extends Event
  17. {
  18. private $event;
  19. /**
  20. * @param object $event
  21. */
  22. public function __construct($event)
  23. {
  24. $this->event = $event;
  25. }
  26. /**
  27. * @return object $event
  28. */
  29. public function getEvent()
  30. {
  31. return $this->event;
  32. }
  33. public function isPropagationStopped(): bool
  34. {
  35. if (!$this->event instanceof ContractsEvent && !$this->event instanceof StoppableEventInterface) {
  36. return false;
  37. }
  38. return $this->event->isPropagationStopped();
  39. }
  40. public function stopPropagation()
  41. {
  42. if (!$this->event instanceof ContractsEvent) {
  43. return;
  44. }
  45. $this->event->stopPropagation();
  46. }
  47. public function __call($name, $args)
  48. {
  49. return $this->event->{$name}(...$args);
  50. }
  51. }