aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php')
-rw-r--r--vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php92
1 files changed, 92 insertions, 0 deletions
diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
new file mode 100644
index 00000000..b70b81a8
--- /dev/null
+++ b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php
@@ -0,0 +1,92 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\EventDispatcher;
13
14/**
15 * A read-only proxy for an event dispatcher.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class ImmutableEventDispatcher implements EventDispatcherInterface
20{
21 /**
22 * The proxied dispatcher.
23 * @var EventDispatcherInterface
24 */
25 private $dispatcher;
26
27 /**
28 * Creates an unmodifiable proxy for an event dispatcher.
29 *
30 * @param EventDispatcherInterface $dispatcher The proxied event dispatcher.
31 */
32 public function __construct(EventDispatcherInterface $dispatcher)
33 {
34 $this->dispatcher = $dispatcher;
35 }
36
37 /**
38 * {@inheritdoc}
39 */
40 public function dispatch($eventName, Event $event = null)
41 {
42 return $this->dispatcher->dispatch($eventName, $event);
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 public function addListener($eventName, $listener, $priority = 0)
49 {
50 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function addSubscriber(EventSubscriberInterface $subscriber)
57 {
58 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function removeListener($eventName, $listener)
65 {
66 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
67 }
68
69 /**
70 * {@inheritdoc}
71 */
72 public function removeSubscriber(EventSubscriberInterface $subscriber)
73 {
74 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function getListeners($eventName = null)
81 {
82 return $this->dispatcher->getListeners($eventName);
83 }
84
85 /**
86 * {@inheritdoc}
87 */
88 public function hasListeners($eventName = null)
89 {
90 return $this->dispatcher->hasListeners($eventName);
91 }
92}