1 | <?php |
||
30 | trait DelegatorTrait |
||
31 | { |
||
32 | /** |
||
33 | * lookup pool of registries |
||
34 | * |
||
35 | * @var array |
||
36 | * @access protected |
||
37 | */ |
||
38 | protected $lookup_pool = []; |
||
39 | |||
40 | /** |
||
41 | * cached found key |
||
42 | * |
||
43 | * @var string |
||
44 | * @access private |
||
45 | */ |
||
46 | private $cache_key; |
||
47 | |||
48 | /** |
||
49 | * cached lookup registry for found $cache_key |
||
50 | * |
||
51 | * @var object |
||
52 | * @access private |
||
53 | */ |
||
54 | private $cache_reg; |
||
55 | |||
56 | /** |
||
57 | * Append one registry to lookup pool |
||
58 | * |
||
59 | * @param object $registry |
||
60 | * @return $this |
||
61 | * @access protected |
||
62 | */ |
||
63 | protected function addRegistry($registry) |
||
78 | |||
79 | /** |
||
80 | * check existence in the whole lookup pool |
||
81 | * |
||
82 | * @param string $key |
||
83 | * @return bool |
||
84 | * @access protected |
||
85 | */ |
||
86 | protected function hasInLookup(/*# string */ $key)/*# : bool */ |
||
97 | |||
98 | /** |
||
99 | * get from lookup pool, return NULL if not found |
||
100 | * |
||
101 | * @param string $key |
||
102 | * @return mixed|null |
||
103 | * @access protected |
||
104 | */ |
||
105 | protected function getFromLookup(/*# string */ $key) |
||
114 | |||
115 | /** |
||
116 | * Remove one registry from the pool |
||
117 | * |
||
118 | * @param object $registry |
||
119 | * @return $this |
||
120 | * @access protected |
||
121 | */ |
||
122 | protected function removeFromLookup($registry) |
||
134 | |||
135 | /** |
||
136 | * Clear lookup cache |
||
137 | * |
||
138 | * @access protected |
||
139 | */ |
||
140 | protected function clearLookupCache() |
||
144 | |||
145 | /** |
||
146 | * Try HAS in registry |
||
147 | * |
||
148 | * @param object $registry |
||
149 | * @param string $key |
||
150 | * @return bool |
||
151 | * @access protected |
||
152 | */ |
||
153 | abstract protected function hasInRegistry( |
||
157 | |||
158 | /** |
||
159 | * Try GET from registry |
||
160 | * |
||
161 | * @param object $registry |
||
162 | * @param string $key |
||
163 | * @return mixed|null |
||
164 | * @access protected |
||
165 | */ |
||
166 | abstract protected function getFromRegistry( |
||
170 | } |
||
171 |