4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\EventDispatcher;
15 * A read-only proxy for an event dispatcher.
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 class ImmutableEventDispatcher implements EventDispatcherInterface
23 public function __construct(EventDispatcherInterface $dispatcher)
25 $this->dispatcher = $dispatcher;
31 public function dispatch($eventName, Event $event = null)
33 return $this->dispatcher->dispatch($eventName, $event);
39 public function addListener($eventName, $listener, $priority = 0)
41 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
47 public function addSubscriber(EventSubscriberInterface $subscriber)
49 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
55 public function removeListener($eventName, $listener)
57 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
63 public function removeSubscriber(EventSubscriberInterface $subscriber)
65 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
71 public function getListeners($eventName = null)
73 return $this->dispatcher->getListeners($eventName);
79 public function getListenerPriority($eventName, $listener)
81 return $this->dispatcher->getListenerPriority($eventName, $listener);
87 public function hasListeners($eventName = null)
89 return $this->dispatcher->hasListeners($eventName);