1 | <?php |
||
12 | trait DelegatesAwareTrait |
||
13 | { |
||
14 | /** |
||
15 | * Holds a list of all delegate objects. |
||
16 | * |
||
17 | * @var EntityInterface[] |
||
18 | */ |
||
19 | private $delegates = []; |
||
20 | |||
21 | /** |
||
22 | * Assigns a collection of delegare objects. |
||
23 | * |
||
24 | * @param EntityInterface[] $delegates One or more delegate objects to register. |
||
25 | * @return self |
||
26 | */ |
||
27 | final public function setDelegates(array $delegates) |
||
35 | |||
36 | /** |
||
37 | * Appends a delegare object onto the delegate stack. |
||
38 | * |
||
39 | * @param EntityInterface $delegate A delegate object to register. |
||
40 | * @return self |
||
41 | */ |
||
42 | final public function addDelegate(EntityInterface $delegate) |
||
47 | |||
48 | /** |
||
49 | * Prepends a delegare object onto the delegate stack. |
||
50 | * |
||
51 | * @param EntityInterface $delegate A delegate object to register. |
||
52 | * @return self |
||
53 | */ |
||
54 | final public function prependDelegate(EntityInterface $delegate) |
||
59 | |||
60 | /** |
||
61 | * Determines if a delegate object contains the specified key and if its value is not NULL. |
||
62 | * |
||
63 | * Iterates over each object in the delegate stack and stops on |
||
64 | * the first match containing the specified key. |
||
65 | * |
||
66 | * @param string $key The data key to check. |
||
67 | * @return boolean TRUE if $key exists and has a value other than NULL, FALSE otherwise. |
||
68 | */ |
||
69 | final protected function hasInDelegates($key) |
||
78 | |||
79 | /** |
||
80 | * Returns the value from the specified key found on the first delegate object. |
||
81 | * |
||
82 | * Iterates over each object in the delegate stack and stops on |
||
83 | * the first match containing a value that is not NULL. |
||
84 | * |
||
85 | * @param string $key The data key to retrieve. |
||
86 | * @return mixed Value of the requested $key on success, NULL if the $key is not set. |
||
87 | */ |
||
88 | final protected function getInDelegates($key) |
||
97 | } |
||
98 |