1 | <?php |
||
31 | trait UserOrganizationTrait |
||
32 | { |
||
33 | public $organizationClass = Organization::class; |
||
34 | public $memberClass = Member::class; |
||
35 | private $noInitOrganization; |
||
36 | private $noInitMember; |
||
37 | public $lastSetUpOrganization; |
||
38 | /** |
||
39 | * @return Organization |
||
40 | */ |
||
41 | protected function getNoInitOrganization() |
||
49 | /** |
||
50 | * @return Member |
||
51 | */ |
||
52 | 17 | protected function getNoInitMember() |
|
60 | |||
61 | /** |
||
62 | * |
||
63 | * @return MemberQuery |
||
64 | */ |
||
65 | 17 | public function getOfMembers() |
|
69 | |||
70 | /** |
||
71 | * |
||
72 | * @return OrganizationQuery |
||
73 | */ |
||
74 | 8 | public function getAtOrganizations() |
|
78 | |||
79 | /** |
||
80 | * Set up organization. |
||
81 | * @param string $name |
||
82 | * @param Organization $parent |
||
83 | * @param string $nickname |
||
84 | * @param integer $gravatar_type |
||
85 | * @param string $gravatar |
||
86 | * @param string $timezone |
||
87 | * @param string $description |
||
88 | * @return boolean Whether indicate the setting-up succeeded or not. |
||
89 | */ |
||
90 | 24 | public function setUpOrganization($name, $parent = null, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '') |
|
105 | |||
106 | /** |
||
107 | * Set up organization. |
||
108 | * @param string $name |
||
109 | * @param Organization $parent |
||
110 | * @param string $nickname |
||
111 | * @param integer $gravatar_type |
||
112 | * @param string $gravatar |
||
113 | * @param string $timezone |
||
114 | * @param string $description |
||
115 | * @return boolean Whether indicate the setting-up succeeded or not. |
||
116 | */ |
||
117 | 3 | public function setUpDepartment($name, $parent = null, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '') |
|
135 | |||
136 | /** |
||
137 | * Set up base organization. |
||
138 | * @param array $models |
||
139 | * @return boolean |
||
140 | * @throws InvalidConfigException |
||
141 | * @throws \Exception |
||
142 | */ |
||
143 | 24 | protected function setUpBaseOrganization($models) |
|
158 | |||
159 | /** |
||
160 | * Create organization. |
||
161 | * @param string $name |
||
162 | * @param Organization $parent |
||
163 | * @param string $nickname |
||
164 | * @param string $gravatar_type |
||
165 | * @param string $gravatar |
||
166 | * @param string $timezone |
||
167 | * @param string $description |
||
168 | * @return Organization |
||
169 | */ |
||
170 | 23 | public function createOrganization($name, $parent = null, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '') |
|
174 | |||
175 | /** |
||
176 | * Create department. |
||
177 | * @param string $name |
||
178 | * @param Organization $parent |
||
179 | * @param string $nickname |
||
180 | * @param string $gravatar_type |
||
181 | * @param string $gravatar |
||
182 | * @param string $timezone |
||
183 | * @param string $description |
||
184 | * @return Organization |
||
185 | */ |
||
186 | 1 | public function createDepartment($name, $parent = null, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '') |
|
190 | |||
191 | /** |
||
192 | * Create Base Organization. |
||
193 | * @param string $name |
||
194 | * @param Organization $parent |
||
195 | * @param string $nickname |
||
196 | * @param integer $gravatar_type |
||
197 | * @param string $gravatar |
||
198 | * @param string $timezone |
||
199 | * @param string $description |
||
200 | * @param integer $type |
||
201 | * @return array This array contains two elements, the first is `Organization` or `Department` depends on `$type`. |
||
202 | * The other is `associatedModels` array, contains two elements `Profile`(profile) and `Creator`(creator). |
||
203 | * @throws InvalidParamException throw if setting parent failed. Possible reasons include: |
||
204 | * - The parent is itself. |
||
205 | * - The parent has already been its ancestor. |
||
206 | * - The current organization has reached the limit of ancestors. |
||
207 | */ |
||
208 | 23 | protected function createBaseOrganization($name, $parent = null, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '', $type = Organization::TYPE_ORGANIZATION) |
|
237 | |||
238 | /** |
||
239 | * Revoke organization. |
||
240 | * @param static|string|integer $organization |
||
241 | * @param boolean $revokeIfHasChildren |
||
242 | * @throws InvalidParamException throw if current user is not the creator of organization. |
||
243 | */ |
||
244 | 1 | public function revokeOrganization($organization, $revokeIfHasChildren = false) |
|
275 | |||
276 | /** |
||
277 | * |
||
278 | * @param Organization $organization |
||
279 | */ |
||
280 | 1 | public function isOrganizationCreator($organization) |
|
288 | |||
289 | /** |
||
290 | * |
||
291 | * @param Organization $organization |
||
292 | */ |
||
293 | 2 | public function isOrganizationAdministrator($organization) |
|
301 | } |
||
302 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.