Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\EventDispatcher; Chris@0: Chris@0: /** Chris@0: * A read-only proxy for an event dispatcher. Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: class ImmutableEventDispatcher implements EventDispatcherInterface Chris@0: { Chris@0: private $dispatcher; Chris@0: Chris@0: public function __construct(EventDispatcherInterface $dispatcher) Chris@0: { Chris@0: $this->dispatcher = $dispatcher; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function dispatch($eventName, Event $event = null) Chris@0: { Chris@0: return $this->dispatcher->dispatch($eventName, $event); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function addListener($eventName, $listener, $priority = 0) Chris@0: { Chris@0: throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function addSubscriber(EventSubscriberInterface $subscriber) Chris@0: { Chris@0: throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function removeListener($eventName, $listener) Chris@0: { Chris@0: throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function removeSubscriber(EventSubscriberInterface $subscriber) Chris@0: { Chris@0: throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getListeners($eventName = null) Chris@0: { Chris@0: return $this->dispatcher->getListeners($eventName); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getListenerPriority($eventName, $listener) Chris@0: { Chris@0: return $this->dispatcher->getListenerPriority($eventName, $listener); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function hasListeners($eventName = null) Chris@0: { Chris@0: return $this->dispatcher->hasListeners($eventName); Chris@0: } Chris@0: }