1 | <?php |
||
31 | trait DelegatorTrait |
||
32 | { |
||
33 | /** |
||
34 | * lookup pool of registries |
||
35 | * |
||
36 | * @var array |
||
37 | * @access protected |
||
38 | */ |
||
39 | protected $lookup_pool = []; |
||
40 | |||
41 | /** |
||
42 | * cached lookup key |
||
43 | * |
||
44 | * @var string |
||
45 | * @access private |
||
46 | */ |
||
47 | private $cache_key; |
||
48 | |||
49 | /** |
||
50 | * cached lookup registry |
||
51 | * |
||
52 | * @var object |
||
53 | * @access private |
||
54 | */ |
||
55 | private $cache_reg; |
||
56 | |||
57 | /** |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | public function addRegistry($registry) |
||
83 | |||
84 | /** |
||
85 | * {@inheritDoc} |
||
86 | */ |
||
87 | public function clearAllRegistries() |
||
92 | |||
93 | /** |
||
94 | * {@inheritDoc} |
||
95 | */ |
||
96 | public function hasInLookup(/*# string */ $key)/*# : bool */ |
||
107 | |||
108 | /** |
||
109 | * {@inheritDoc} |
||
110 | */ |
||
111 | public function getFromLookup(/*# string */ $key) |
||
120 | |||
121 | /** |
||
122 | * Remove one object from the pool |
||
123 | * |
||
124 | * @param object $registry |
||
125 | * @return $this |
||
126 | * @access protected |
||
127 | */ |
||
128 | protected function removeFromLookup($registry) |
||
137 | |||
138 | /** |
||
139 | * Is registry type allowed in lookup pool ? |
||
140 | * |
||
141 | * @param object $registry |
||
142 | * @return bool |
||
143 | * @access protected |
||
144 | */ |
||
145 | abstract protected function isValidRegistry($registry)/*# : bool */; |
||
146 | |||
147 | /** |
||
148 | * Try has in registry |
||
149 | * |
||
150 | * @param object $registry |
||
151 | * @param name $key |
||
152 | * @return bool |
||
153 | * @access protected |
||
154 | */ |
||
155 | abstract protected function hasInRegistry( |
||
159 | |||
160 | /** |
||
161 | * Try get from registry |
||
162 | * |
||
163 | * @param object $registry |
||
164 | * @param name $key |
||
165 | * @return mixed |
||
166 | * @access protected |
||
167 | */ |
||
168 | abstract protected function getFromRegistry( |
||
172 | } |
||
173 |