1 | <?php |
||
31 | trait UserInvitationRegistrationTrait |
||
32 | { |
||
33 | public $invitationRegistrationClass = Registration::class; |
||
34 | /** |
||
35 | * @param array $associatedModels |
||
36 | * @param array $authRoles |
||
37 | * @param User $inviter |
||
38 | * @return boolean |
||
39 | * @throws \Exception |
||
40 | * @throws InvalidParamException |
||
41 | */ |
||
42 | 6 | public function registerAccordingToInvitation($associatedModels = [], $authRoles = [], $inviter) |
|
43 | { |
||
44 | 6 | if (!$inviter) { |
|
45 | return false; |
||
46 | } |
||
47 | 6 | if ($inviter instanceof User && $inviter->getIsNewRecord()) { |
|
48 | throw new InvalidParamException("Inviter cannot be a new user."); |
||
49 | } |
||
50 | 6 | $transaction = Yii::$app->db->beginTransaction(); |
|
51 | try { |
||
52 | 6 | $result = $this->register($associatedModels, $authRoles); |
|
|
|||
53 | 6 | if ($result instanceof \Exception) { |
|
54 | throw $result; |
||
55 | } |
||
56 | 6 | if ($result !== true) { |
|
57 | throw new IntegrityException("Registration Failed."); |
||
58 | } |
||
59 | 6 | $invitation = $inviter->createInvitationRegistration($this); |
|
60 | 6 | $result = $invitation->save(); |
|
61 | 6 | if (!$result) { |
|
62 | throw new IntegrityException("Record Invitation Failed."); |
||
63 | } |
||
64 | 6 | $transaction->commit(); |
|
65 | 6 | } catch (\Exception $ex) { |
|
66 | $transaction->rollBack(); |
||
67 | throw $ex; |
||
68 | } |
||
69 | 6 | return true; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Create a registration invitation instance. |
||
74 | * @param string|User $invitee The invited person. |
||
75 | * @return Registration |
||
76 | */ |
||
77 | 6 | public function createInvitationRegistration($invitee) |
|
81 | |||
82 | /** |
||
83 | * Check whether this user enables the invitation from registration feature or not. |
||
84 | * @return boolean |
||
85 | */ |
||
86 | 7 | public function hasEnabledInvitationRegistration() |
|
93 | |||
94 | /** |
||
95 | * @return BaseBlameableQuery |
||
96 | */ |
||
97 | 7 | public function getInvitationRegistrations() |
|
107 | |||
108 | /** |
||
109 | * @return User[] |
||
110 | */ |
||
111 | 1 | public function getInvitationRegistrationInvitees() |
|
115 | } |
||
116 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.