1 | <?php |
||
26 | class Delegate |
||
27 | { |
||
28 | /** @type array list of callbacks */ |
||
29 | public $callbacks = null; |
||
30 | /** @type mixed stop propagation if false is returned */ |
||
31 | public $stopPropagationWithReturn = true; |
||
32 | /** @type bool priorities sorted or not */ |
||
33 | private $prioritiesSorted = true; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * Constructs a new delegate in order to assign it to a member |
||
38 | * |
||
39 | * @return Delegate a delegate |
||
40 | */ |
||
41 | public static function assign() |
||
53 | |||
54 | // @codingStandardsIgnoreStart |
||
55 | /** |
||
56 | * Unserializes an instance of delegate |
||
57 | * |
||
58 | * @param array $uPropertyBag properties set of unserialized object |
||
59 | * |
||
60 | * @return Delegate a delegate |
||
61 | */ |
||
62 | public static function __set_state(array $uPropertyBag) |
||
69 | // @codingStandardsIgnoreEnd |
||
70 | |||
71 | /** |
||
72 | * Subscribes a callback to delegate |
||
73 | * |
||
74 | * @param callback $uCallback callback method |
||
75 | * @param mixed $uState state object |
||
76 | * @param null|int $uPriority priority level |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public function subscribe(/* callable */ $uCallback, $uState = null, $uPriority = null) |
||
93 | |||
94 | /** |
||
95 | * Invokes the event-chain execution |
||
96 | * |
||
97 | * @param array $uParameters execution parameters |
||
98 | * |
||
99 | * @return bool whether the propagation is stopped or not |
||
100 | */ |
||
101 | public function invoke(...$uParameters) |
||
118 | |||
119 | /** |
||
120 | * Sorts callbacks in order to their priority |
||
121 | * |
||
122 | * @param int $uFirst first array item |
||
123 | * @param int $uSecond second array item |
||
124 | * |
||
125 | * @return int comparision result that indicates which item comes first |
||
126 | */ |
||
127 | private function prioritySort($uFirst, $uSecond) |
||
139 | } |
||
140 |