1 | <?php |
||
19 | trait EventsAwareTrait |
||
20 | { |
||
21 | /** |
||
22 | * @var EventManagerInterface |
||
23 | */ |
||
24 | protected $events; |
||
25 | |||
26 | /** |
||
27 | * Set the event manager instance used by this context. |
||
28 | * |
||
29 | * For convenience, this method will also set the class name / LSB name as |
||
30 | * identifiers, in addition to any string or array of strings set to the |
||
31 | * $this->eventIdentifier property. |
||
32 | * |
||
33 | * @param EventManagerInterface $events |
||
34 | * @return mixed |
||
35 | */ |
||
36 | public function setEvents(EventManagerInterface $events) |
||
57 | |||
58 | /** |
||
59 | * Retrieve the event manager |
||
60 | * |
||
61 | * Lazy-loads an EventManager instance if none registered. |
||
62 | * |
||
63 | * @return EventManagerInterface |
||
64 | */ |
||
65 | public function getEvents() |
||
72 | } |
||
73 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: