1 | <?php |
||
29 | trait ShareableTrait |
||
30 | { |
||
31 | /** |
||
32 | * Shareables' pool |
||
33 | * |
||
34 | * @var ShareableInstance[] |
||
35 | * @access private |
||
36 | * @staticvar |
||
37 | */ |
||
38 | private static $shareables = []; |
||
39 | |||
40 | /** |
||
41 | * Is this shared instance, store scope here |
||
42 | * |
||
43 | * @var string |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected $shared_in; |
||
47 | |||
48 | /** |
||
49 | * Scopes of this instance belongs to |
||
50 | * |
||
51 | * @var string[] |
||
52 | * @access protected |
||
53 | */ |
||
54 | protected $scopes = []; |
||
55 | |||
56 | /** |
||
57 | * minimum constructor |
||
58 | * |
||
59 | * @access public |
||
60 | */ |
||
61 | public function __construct() |
||
64 | |||
65 | /* |
||
66 | * {@inheritDoc} |
||
67 | */ |
||
68 | public static function getShareable( |
||
78 | |||
79 | /** |
||
80 | * {@inheritDoc} |
||
81 | */ |
||
82 | public static function hasShareable(/*# string */ $scope = '')/*# : bool */ |
||
86 | |||
87 | /** |
||
88 | * {@inheritDoc} |
||
89 | */ |
||
90 | public static function clearShareable(/*# string */ $scope = '') |
||
98 | |||
99 | /** |
||
100 | * {@inheritDoc} |
||
101 | */ |
||
102 | public function setShareable(/*# string */ $scope = '') |
||
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | public function addScope(/*# string */ $scope) |
||
141 | |||
142 | /** |
||
143 | * {@inheritDoc} |
||
144 | */ |
||
145 | public function hasScope(/*# string */ $scope = '')/*# : bool */ |
||
149 | |||
150 | /** |
||
151 | * {@inheritDoc} |
||
152 | */ |
||
153 | public function getShareables()/*# : array */ |
||
161 | |||
162 | /** |
||
163 | * {@inheritDoc} |
||
164 | */ |
||
165 | public function isShareable() |
||
169 | |||
170 | /** |
||
171 | * Get all unique scopes for $this if not a shared instance |
||
172 | * |
||
173 | * @return array |
||
174 | * @access protected |
||
175 | */ |
||
176 | protected function getScopes()/*# : array */ |
||
194 | |||
195 | /** |
||
196 | * Split a scope of 'vendor.app' into ['vendor.app', 'vendor'] |
||
197 | * |
||
198 | * @param string $scope |
||
199 | * @return array |
||
200 | * @access protected |
||
201 | */ |
||
202 | protected function splitScope(/*# string */ $scope)/*# : array */ |
||
214 | } |
||
215 |