1 | <?php |
||
56 | class EventDispatcher |
||
57 | { |
||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $observers; |
||
62 | |||
63 | /** |
||
64 | * @var EventDispatcher |
||
65 | */ |
||
66 | protected static $instance; |
||
67 | |||
68 | /** |
||
69 | * The __constructor is private because the dispatcher is a singleton |
||
70 | * |
||
71 | * @return void |
||
|
|||
72 | * |
||
73 | * @deprecated since crawler v6.4.0, will be removed in crawler v7.0.0. |
||
74 | */ |
||
75 | protected function __construct() |
||
88 | |||
89 | /** |
||
90 | * Returns all registered event types. |
||
91 | * |
||
92 | * @return array array with registered events. |
||
93 | */ |
||
94 | protected function getEvents() |
||
98 | |||
99 | /** |
||
100 | * This method can be used to add an observer for an event to the dispatcher |
||
101 | * |
||
102 | * @param EventObserverInterface $observer_object |
||
103 | * @param string $observer_method |
||
104 | * @param string $event |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | 4 | public function addObserver(EventObserverInterface $observer_object, $observer_method, $event) |
|
112 | |||
113 | /** |
||
114 | * Enables checking whether a certain event is observed by anyone |
||
115 | * |
||
116 | * @param string $event |
||
117 | * |
||
118 | * @return boolean |
||
119 | */ |
||
120 | public function hasObserver($event) |
||
124 | |||
125 | /** |
||
126 | * This method should be used to post a event to the dispatcher. Each |
||
127 | * registered observer will be notified about the event. |
||
128 | * |
||
129 | * @param string $event |
||
130 | * @param string $group |
||
131 | * @param mixed $attachedData |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | 4 | public function post($event, $group, $attachedData) |
|
143 | |||
144 | /** |
||
145 | * Returns the instance of the dispatcher singleton |
||
146 | * |
||
147 | * @return EventDispatcher |
||
148 | */ |
||
149 | public static function getInstance() |
||
158 | } |
||
159 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.