Lines
100.00%
6 / 6
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RoleDelete | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 2 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsadmin; | |
| 4 | ||
| 5 | use BO\Mellon\Validator; | |
| 6 | use BO\Zmsentities\Exception\UserAccountMissingRights; | |
| 7 | ||
| 8 | class RoleDelete extends BaseController | |
| 9 | { | |
| 10 | /** | |
| 11 | * @return \Psr\Http\Message\ResponseInterface | |
| 12 | */ | |
| 13 | #[\Override] | |
| 14 | public function readResponse( | |
| 15 | \Psr\Http\Message\RequestInterface $request, | |
| 16 | \Psr\Http\Message\ResponseInterface $response, | |
| 17 | array $args | |
| 18 | ) { | |
| 19 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); | |
| 20 | if (!$workstation->getUseraccount()->hasPermissions(['superuser'])) { | |
| 21 | throw new UserAccountMissingRights(); | |
| 22 | } | |
| 23 | ||
| 24 | $roleId = (int) Validator::value($args['id'] ?? null)->isNumber()->getValue(); | |
| 25 | \App::$http->readDeleteResult('/roles/' . $roleId . '/', [])->getEntity(); | |
| 26 | ||
| 27 | return $response->withStatus(204); | |
| 28 | } | |
| 29 | } |