comparison vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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
12 namespace Symfony\Component\EventDispatcher;
13
14 /**
15 * A read-only proxy for an event dispatcher.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19 class ImmutableEventDispatcher implements EventDispatcherInterface
20 {
21 /**
22 * The proxied dispatcher.
23 *
24 * @var EventDispatcherInterface
25 */
26 private $dispatcher;
27
28 /**
29 * Creates an unmodifiable proxy for an event dispatcher.
30 *
31 * @param EventDispatcherInterface $dispatcher The proxied event dispatcher
32 */
33 public function __construct(EventDispatcherInterface $dispatcher)
34 {
35 $this->dispatcher = $dispatcher;
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function dispatch($eventName, Event $event = null)
42 {
43 return $this->dispatcher->dispatch($eventName, $event);
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function addListener($eventName, $listener, $priority = 0)
50 {
51 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function addSubscriber(EventSubscriberInterface $subscriber)
58 {
59 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
60 }
61
62 /**
63 * {@inheritdoc}
64 */
65 public function removeListener($eventName, $listener)
66 {
67 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
68 }
69
70 /**
71 * {@inheritdoc}
72 */
73 public function removeSubscriber(EventSubscriberInterface $subscriber)
74 {
75 throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
76 }
77
78 /**
79 * {@inheritdoc}
80 */
81 public function getListeners($eventName = null)
82 {
83 return $this->dispatcher->getListeners($eventName);
84 }
85
86 /**
87 * {@inheritdoc}
88 */
89 public function getListenerPriority($eventName, $listener)
90 {
91 return $this->dispatcher->getListenerPriority($eventName, $listener);
92 }
93
94 /**
95 * {@inheritdoc}
96 */
97 public function hasListeners($eventName = null)
98 {
99 return $this->dispatcher->hasListeners($eventName);
100 }
101 }