1 | <?php |
||
24 | trait CallbackChainHelperTrait |
||
25 | { |
||
26 | /** |
||
27 | * Determines if the current callback-chain should be terminated at the |
||
28 | * next iteration |
||
29 | * |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $terminateCallbackChain = false; |
||
33 | /** |
||
34 | * Callback execution status |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | private $inCallbackChain = false; |
||
39 | |||
40 | /** |
||
41 | * Terminate callback chain from inside a callback |
||
42 | * |
||
43 | * This method may be called from inside of a callback chain to break out in the next iteration * |
||
44 | * |
||
45 | * @throws \LogicException Thrown if no callback chain is executing when called |
||
46 | */ |
||
47 | 14 | public function terminateCallbackChain() |
|
55 | |||
56 | /** |
||
57 | * Modify the status of current callback execution |
||
58 | * |
||
59 | * This method can be used by the callback calling code to make sure other methods react |
||
60 | * properly. |
||
61 | * |
||
62 | * @param bool $areWeInCallbackChain Set the status of the callback chain execution |
||
63 | * @see CallbackChainHelperTrait::terminateCallbackChain() Dependent method |
||
64 | * @see CallbackChainHelperTrait::isCallbackChainToBeTerminated() Dependent method |
||
65 | */ |
||
66 | 82 | protected function inCallbackChain($areWeInCallbackChain) |
|
70 | |||
71 | /** |
||
72 | * Get the status of the callback chain termination |
||
73 | * |
||
74 | * This method can be used to determine if the callback chain is to be terminated prematurely. |
||
75 | * |
||
76 | * @return bool |
||
77 | */ |
||
78 | 80 | protected function isCallbackChainToBeTerminated() |
|
82 | |||
83 | /** |
||
84 | * Mark callback chain terminated |
||
85 | * |
||
86 | * This method should be called after the callback chain was terminated, either by breaking out of it prematurely |
||
87 | * or after finishing all callback handlers. |
||
88 | */ |
||
89 | 82 | protected function markCallbackChainTerminated() |
|
94 | } |
||
95 |