1 | <?php |
||
30 | trait ScopeTrait |
||
31 | { |
||
32 | use ContainerHelperTrait; |
||
33 | |||
34 | /** |
||
35 | * default scope for objects |
||
36 | * |
||
37 | * @var string |
||
38 | * @access protected |
||
39 | */ |
||
40 | protected $default_scope = ScopeInterface::SCOPE_SHARED; |
||
41 | |||
42 | /** |
||
43 | * Split 'service_id@scope' into ['service_id', 'scope'] |
||
44 | * |
||
45 | * if no scope found, use '' |
||
46 | * |
||
47 | * @param string $id |
||
48 | * @return array [$id, $scope] |
||
49 | * @access protected |
||
50 | */ |
||
51 | protected function splitId(/*# string */ $id)/*# : array */ |
||
59 | |||
60 | /** |
||
61 | * Return the raw id without scope |
||
62 | * |
||
63 | * @param string $id |
||
64 | * @return string |
||
65 | * @access protected |
||
66 | */ |
||
67 | protected function idWithoutScope(/*# string */ $id)/*# : string */ |
||
71 | |||
72 | /** |
||
73 | * Get the scope part of $id |
||
74 | * |
||
75 | * @param string $id |
||
76 | * @return string |
||
77 | * @access protected |
||
78 | */ |
||
79 | protected function getScopeOfId(/*# string */ $id)/*# : string */ |
||
83 | |||
84 | /** |
||
85 | * Append a scope to the $id, if old scope exists, replace it |
||
86 | * |
||
87 | * @param string $id |
||
88 | * @param string $scope |
||
89 | * @return string |
||
90 | * @access protected |
||
91 | */ |
||
92 | protected function scopedId( |
||
98 | |||
99 | /** |
||
100 | * Returns the raw id and the scope base on default or defined |
||
101 | * |
||
102 | * @param string $id |
||
103 | * @return array [rawId, scope] |
||
104 | * @access protected |
||
105 | */ |
||
106 | protected function scopedInfo(/*# string */ $id)/*# : array */ |
||
125 | |||
126 | /** |
||
127 | * Append scope to data |
||
128 | * |
||
129 | * @param mixed $data |
||
130 | * @param string $scope |
||
131 | * @return array |
||
132 | * @access protected |
||
133 | */ |
||
134 | protected function scopedData($data, /*# string */ $scope)/*# : array */ |
||
143 | } |
||
144 |