1 | <?php |
||
28 | class events |
||
29 | { |
||
30 | /** |
||
31 | * Factory method for the static stack. Returns the shared stack only. Use new \arc\events\Stack |
||
32 | * or your own factory method to create a seperate Stack instance. |
||
33 | */ |
||
34 | 12 | public static function getEventsTree() |
|
43 | |||
44 | /** |
||
45 | * Returns an IncompleteListener for the given event, objectType and path. |
||
46 | * |
||
47 | * Usage: |
||
48 | * \arc\events::listen( 'onsave' )->call( function ($event) { |
||
49 | * $path = $event->data['arc.path']; |
||
50 | * if ($path == '/foo/bar/') { |
||
51 | * $event->preventDefault(); |
||
52 | * return false; // cancel all other listeners |
||
53 | * } |
||
54 | * }); |
||
55 | * |
||
56 | * @param string $eventName The name of the event to listen for. |
||
57 | * @return IncompleteListener |
||
58 | */ |
||
59 | 10 | public static function listen($eventName, $callback) |
|
63 | |||
64 | /** |
||
65 | * Returns an IncompleteListener for the given event, objectType and path. The listener |
||
66 | * will trigger in the capture phase - before any listeners in the listen phase. |
||
67 | * |
||
68 | * @param string $eventName The name of the event to listen for. |
||
69 | * @return IncompleteListener |
||
70 | */ |
||
71 | 4 | public static function capture($eventName, $callback) |
|
75 | |||
76 | /** |
||
77 | * Fires an event. If the event objects preventDefault() method has been called it |
||
78 | * will return false, otherwise the - potentially changed - eventData will be returned. |
||
79 | * |
||
80 | * Usage: |
||
81 | * $eventData = \arc\events::fire( 'onbeforesave', array( 'your' => 'data' ) ); |
||
82 | * if ($eventData) { |
||
83 | * // now save it |
||
84 | * } |
||
85 | * |
||
86 | * @param string $eventName The name of the event to fire. |
||
87 | * @param mixed $eventData Optional. Data passed to each handler through the event object. |
||
88 | * @return false or $eventData - which may have been modified |
||
89 | */ |
||
90 | 6 | public static function fire( $eventName, $eventData = array() ) |
|
94 | |||
95 | /** |
||
96 | * Returns a new IncompleteListener with the given path. |
||
97 | * @param string $path The path to change to, may be a relative path. |
||
98 | * @return IncompleteListener |
||
99 | */ |
||
100 | 8 | public static function cd($path) |
|
104 | } |
||
105 |