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 | * {@inheritDoc} |
||
58 | */ |
||
59 | public static function getShareable( |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | public static function hasShareable(/*# string */ $scope = '')/*# : bool */ |
||
77 | |||
78 | /** |
||
79 | * {@inheritDoc} |
||
80 | */ |
||
81 | public static function clearShareable(/*# string */ $scope = '') |
||
89 | |||
90 | /** |
||
91 | * {@inheritDoc} |
||
92 | */ |
||
93 | public function setShareable(/*# string */ $scope = '') |
||
108 | |||
109 | /** |
||
110 | * {@inheritDoc} |
||
111 | */ |
||
112 | public function addScope(/*# string */ $scope) |
||
121 | |||
122 | /** |
||
123 | * {@inheritDoc} |
||
124 | */ |
||
125 | public function hasScope(/*# string */ $scope = '')/*# : bool */ |
||
129 | |||
130 | /** |
||
131 | * {@inheritDoc} |
||
132 | */ |
||
133 | public function getShareables()/*# : array */ |
||
141 | |||
142 | /** |
||
143 | * {@inheritDoc} |
||
144 | */ |
||
145 | public function isShareable() |
||
149 | |||
150 | /** |
||
151 | * Get all unique scopes for $this if not a shared instance |
||
152 | * |
||
153 | * @return array |
||
154 | * @access protected |
||
155 | */ |
||
156 | protected function getScopes()/*# : array */ |
||
174 | |||
175 | /** |
||
176 | * Split a scope of 'vendor.app' into ['vendor.app', 'vendor'] |
||
177 | * |
||
178 | * @param string $scope |
||
179 | * @return array |
||
180 | * @access protected |
||
181 | */ |
||
182 | protected function splitScope(/*# string */ $scope)/*# : array */ |
||
194 | } |
||
195 |