1 | <?php |
||
37 | class Member extends BaseBlameableModel |
||
38 | { |
||
39 | public $createdByAttribute = 'organization_guid'; |
||
40 | public $updatedByAttribute = false; |
||
41 | public $hostClass = Organization::class; |
||
42 | |||
43 | public $memberAttribute = 'user_guid'; |
||
44 | public $memberUserClass = User::class; |
||
45 | public $contentAttribute = 'nickname'; |
||
46 | private $noInitMemberUser; |
||
47 | /** |
||
48 | * @return User |
||
49 | */ |
||
50 | 6 | protected function getNoInitMemberUser() |
|
51 | { |
||
52 | 6 | if (!$this->noInitMemberUser) { |
|
53 | 6 | $class = $this->memberUserClass; |
|
54 | 6 | $this->noInitMemberUser = $class::buildNoInitModel(); |
|
55 | 6 | } |
|
56 | 6 | return $this->noInitMemberUser; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | 10 | public function init() |
|
63 | { |
||
64 | 10 | if (!is_string($this->queryClass)) { |
|
65 | 10 | $this->queryClass = MemberQuery::class; |
|
66 | 10 | } |
|
67 | 10 | if ($this->skipInit) { |
|
68 | 10 | return; |
|
69 | } |
||
70 | 10 | parent::init(); |
|
71 | 10 | } |
|
72 | |||
73 | public $descriptionAttribute = 'description'; |
||
74 | |||
75 | 10 | public function getMemberUserRules() |
|
76 | { |
||
77 | return [ |
||
78 | 10 | [$this->memberAttribute, 'required'], |
|
79 | 10 | [$this->memberAttribute, 'string', 'max' => 36], |
|
80 | 10 | ]; |
|
81 | } |
||
82 | |||
83 | 10 | public function getMemberRoleRules() |
|
84 | { |
||
85 | return [ |
||
86 | 10 | ['role', 'string', 'max' => 255], |
|
87 | 10 | ]; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * Set member user. |
||
92 | * @param User|string|integer $user |
||
93 | */ |
||
94 | 10 | public function setMemberUser($user) |
|
95 | { |
||
96 | 10 | $class = $this->memberUserClass; |
|
97 | 10 | if (is_int($user)) { |
|
98 | $user = $class::find()->id($user)->one(); |
||
99 | } |
||
100 | 10 | if ($user instanceof $class) { |
|
101 | 10 | $user = $user->getGUID(); |
|
102 | 10 | } |
|
103 | 10 | $this->user_guid = $user; |
|
104 | 10 | } |
|
105 | |||
106 | 10 | public function getMemberUser() |
|
110 | |||
111 | /** |
||
112 | * Get Organization Query. |
||
113 | * Alias of `getHost` method. |
||
114 | * @return OrganizationQuery |
||
115 | */ |
||
116 | public function getOrganization() |
||
120 | |||
121 | /** |
||
122 | * Set Organization. |
||
123 | * @param BaseOrganization $organization |
||
124 | * @return boolean |
||
125 | */ |
||
126 | 10 | public function setOrganization($organization) |
|
130 | |||
131 | public function assignRole($role) |
||
135 | |||
136 | public function removeRole($role) |
||
140 | |||
141 | 10 | public function rules() |
|
145 | |||
146 | /** |
||
147 | * @inheritdoc |
||
148 | */ |
||
149 | 10 | public static function tableName() |
|
153 | |||
154 | /** |
||
155 | * @inheritdoc |
||
156 | */ |
||
157 | public function attributeLabels() |
||
158 | { |
||
172 | } |
||
173 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.