1 | <?php |
||
29 | trait ShareableTrait |
||
30 | { |
||
31 | /** |
||
32 | * Shareables' pool |
||
33 | * |
||
34 | * @var ShareableInstance[] |
||
35 | * @access protected |
||
36 | * @staticvar |
||
37 | */ |
||
38 | protected 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( |
||
67 | |||
68 | /** |
||
69 | * {@inheritDoc} |
||
70 | */ |
||
71 | public function setShareable(/*# string */ $scope = '') |
||
86 | |||
87 | /** |
||
88 | * {@inheritDoc} |
||
89 | */ |
||
90 | public function isShareable() |
||
94 | |||
95 | /** |
||
96 | * {@inheritDoc} |
||
97 | */ |
||
98 | public function addScope(/*# string */ $scope) |
||
105 | |||
106 | /** |
||
107 | * {@inheritDoc} |
||
108 | */ |
||
109 | public function hasScope(/*# string */ $scope = '')/*# : bool */ |
||
113 | |||
114 | /** |
||
115 | * {@inheritDoc} |
||
116 | */ |
||
117 | public function getShareables()/*# : array */ |
||
125 | |||
126 | /** |
||
127 | * Test existense of shareable in $scope |
||
128 | * |
||
129 | * @param string $scope |
||
130 | * @return bool |
||
131 | * @access protected |
||
132 | */ |
||
133 | protected static function hasShareable( |
||
138 | |||
139 | /** |
||
140 | * Get all unique scopes for $this if not a shared instance |
||
141 | * |
||
142 | * @param string|array $scopes |
||
143 | * @return array |
||
144 | * @access protected |
||
145 | * @static |
||
146 | */ |
||
147 | protected static function getScopes($scopes)/*# : array */ |
||
160 | |||
161 | /** |
||
162 | * Split a scope of 'vendor.app' into ['vendor.app', 'vendor'] |
||
163 | * |
||
164 | * @param string $scope |
||
165 | * @return array |
||
166 | * @access protected |
||
167 | * @static |
||
168 | */ |
||
169 | protected static function splitScope(/*# string */ $scope)/*# : array */ |
||
181 | } |
||
182 |