1 | <?php namespace Anomaly\Streams\Platform\Traits; |
||
13 | trait Hookable |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * The registered hooks. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $hooks = []; |
||
22 | |||
23 | /** |
||
24 | * Register a new hook. |
||
25 | * |
||
26 | * @param $hook |
||
27 | * @param $callback |
||
28 | * @param bool $bind |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function hook($hook, $callback, $bind = false) |
||
39 | |||
40 | /** |
||
41 | * Bind a new hook. This is a shortcut |
||
42 | * for hooks with the bind option. It's |
||
43 | * more descriptive for IDE hinting. |
||
44 | * |
||
45 | * @param $hook |
||
46 | * @param $callback |
||
47 | * @return $this |
||
48 | */ |
||
49 | public function bind($hook, $callback) |
||
53 | |||
54 | /** |
||
55 | * Call a hook. |
||
56 | * |
||
57 | * @param $hook |
||
58 | * @param array $parameters |
||
59 | * @return mixed |
||
60 | */ |
||
61 | public function call($hook, array $parameters = []) |
||
73 | |||
74 | /** |
||
75 | * Return if the hook exists. |
||
76 | * |
||
77 | * @param $hook |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function hasHook($hook) |
||
84 | |||
85 | /** |
||
86 | * Get a hook. |
||
87 | * |
||
88 | * @param $hook |
||
89 | * @return bool |
||
90 | */ |
||
91 | public function getHook($hook) |
||
105 | } |
||
106 |