| @@ 34-52 (lines=19) @@ | ||
| 31 | ->getPassword() === $password; |
|
| 32 | } |
|
| 33 | ||
| 34 | public function getRole($accountId) |
|
| 35 | { |
|
| 36 | if ($this->isExistAccountId($accountId) === false) { |
|
| 37 | return null; |
|
| 38 | } |
|
| 39 | ||
| 40 | $roles = DatabaseManager::getEntityManager() |
|
| 41 | ->getRepository(User::class) |
|
| 42 | ->findOneBy(['accountId' => $accountId]) |
|
| 43 | ->getRoles(); |
|
| 44 | ||
| 45 | $roleArray = []; |
|
| 46 | ||
| 47 | foreach ($roles as $item) { |
|
| 48 | $roleArray[] = $item->getName(); |
|
| 49 | } |
|
| 50 | ||
| 51 | return $roleArray; |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| @@ 18-36 (lines=19) @@ | ||
| 15 | /** |
|
| 16 | * @return array|null |
|
| 17 | */ |
|
| 18 | public function getRolesByOperation($operation) |
|
| 19 | { |
|
| 20 | $roleArray = []; |
|
| 21 | ||
| 22 | /** @var Permission */ |
|
| 23 | $permission = DatabaseManager::getEntityManager() |
|
| 24 | ->getRepository(Permission::class) |
|
| 25 | ->findOneBy(['operation' => $operation]); |
|
| 26 | ||
| 27 | if ($permission === null) { |
|
| 28 | return null; |
|
| 29 | } |
|
| 30 | ||
| 31 | foreach ($permission->getRoles() as $item) { |
|
| 32 | $roleArray[] = $item->getName(); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $roleArray; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||