1 | <?php namespace Modules\User\Repositories\Sentinel; |
||
10 | class SentinelUserRepository implements UserRepository |
||
11 | { |
||
12 | /** |
||
13 | * @var \Modules\User\Entities\Sentinel\User |
||
14 | */ |
||
15 | protected $user; |
||
16 | /** |
||
17 | * @var \Cartalyst\Sentinel\Roles\EloquentRole |
||
18 | */ |
||
19 | protected $role; |
||
20 | |||
21 | public function __construct() |
||
26 | |||
27 | /** |
||
28 | * Returns all the users |
||
29 | * @return object |
||
30 | */ |
||
31 | public function all() |
||
35 | |||
36 | /** |
||
37 | * Create a user resource |
||
38 | * @param $data |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function create(array $data) |
||
45 | |||
46 | /** |
||
47 | * Create a user and assign roles to it |
||
48 | * @param array $data |
||
49 | * @param array $roles |
||
50 | * @param bool $activated |
||
51 | */ |
||
52 | public function createWithRoles($data, $roles, $activated = false) |
||
66 | |||
67 | /** |
||
68 | * Find a user by its ID |
||
69 | * @param $id |
||
70 | * @return mixed |
||
71 | */ |
||
72 | public function find($id) |
||
76 | |||
77 | /** |
||
78 | * Update a user |
||
79 | * @param $user |
||
80 | * @param $data |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function update($user, $data) |
||
91 | |||
92 | /** |
||
93 | * @param $userId |
||
94 | * @param $data |
||
95 | * @param $roles |
||
96 | * @internal param $user |
||
97 | * @return mixed |
||
98 | */ |
||
99 | public function updateAndSyncRoles($userId, $data, $roles) |
||
116 | |||
117 | /** |
||
118 | * Deletes a user |
||
119 | * @param $id |
||
120 | * @throws UserNotFoundException |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function delete($id) |
||
131 | |||
132 | /** |
||
133 | * Find a user by its credentials |
||
134 | * @param array $credentials |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function findByCredentials(array $credentials) |
||
141 | |||
142 | /** |
||
143 | * Hash the password key |
||
144 | * @param array $data |
||
145 | */ |
||
146 | private function hashPassword(array &$data) |
||
150 | |||
151 | /** |
||
152 | * Check if there is a new password given |
||
153 | * If not, unset the password field |
||
154 | * @param array $data |
||
155 | */ |
||
156 | private function checkForNewPassword(array &$data) |
||
166 | |||
167 | /** |
||
168 | * Check and manually activate or remove activation for the user |
||
169 | * @param $user |
||
170 | * @param array $data |
||
171 | */ |
||
172 | private function checkForManualActivation($user, array &$data) |
||
184 | } |
||
185 |