Heimdall/vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php

92 lines
2.2 KiB
PHP
Raw Normal View History

2018-02-01 20:01:12 +00:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher;
/**
* A read-only proxy for an event dispatcher.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ImmutableEventDispatcher implements EventDispatcherInterface
{
2022-11-14 20:15:40 +00:00
private $dispatcher;
2018-02-01 20:01:12 +00:00
public function __construct(EventDispatcherInterface $dispatcher)
{
2022-03-10 11:54:29 +00:00
$this->dispatcher = $dispatcher;
2018-02-01 20:01:12 +00:00
}
/**
* {@inheritdoc}
*/
2022-03-10 11:54:29 +00:00
public function dispatch(object $event, string $eventName = null): object
2018-02-01 20:01:12 +00:00
{
2019-06-11 11:29:32 +00:00
return $this->dispatcher->dispatch($event, $eventName);
2018-02-01 20:01:12 +00:00
}
/**
* {@inheritdoc}
*/
2022-11-14 20:15:40 +00:00
public function addListener(string $eventName, $listener, int $priority = 0)
2018-02-01 20:01:12 +00:00
{
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
}
/**
* {@inheritdoc}
*/
public function addSubscriber(EventSubscriberInterface $subscriber)
{
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
}
/**
* {@inheritdoc}
*/
2022-11-14 20:15:40 +00:00
public function removeListener(string $eventName, $listener)
2018-02-01 20:01:12 +00:00
{
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
}
/**
* {@inheritdoc}
*/
public function removeSubscriber(EventSubscriberInterface $subscriber)
{
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
}
/**
* {@inheritdoc}
*/
2022-11-14 20:15:40 +00:00
public function getListeners(string $eventName = null)
2018-02-01 20:01:12 +00:00
{
return $this->dispatcher->getListeners($eventName);
}
/**
* {@inheritdoc}
*/
2022-11-14 20:15:40 +00:00
public function getListenerPriority(string $eventName, $listener)
2018-02-01 20:01:12 +00:00
{
return $this->dispatcher->getListenerPriority($eventName, $listener);
}
/**
* {@inheritdoc}
*/
2022-11-14 20:15:40 +00:00
public function hasListeners(string $eventName = null)
2018-02-01 20:01:12 +00:00
{
return $this->dispatcher->hasListeners($eventName);
}
}