diff --git a/frontend/modules/api/controllers/ManagerController.php b/frontend/modules/api/controllers/ManagerController.php index 6d75aff..b31a385 100644 --- a/frontend/modules/api/controllers/ManagerController.php +++ b/frontend/modules/api/controllers/ManagerController.php @@ -2,7 +2,6 @@ namespace frontend\modules\api\controllers; - use common\services\ManagerService; use yii\web\NotFoundHttpException; @@ -24,7 +23,7 @@ class ManagerController extends ApiController { $managers = ManagerService::getManagerList(); - if(empty($managers)) { + if (empty($managers)) { throw new NotFoundHttpException('Managers are not assigned'); } @@ -36,14 +35,13 @@ class ManagerController extends ApiController */ public function actionGetManagerEmployeesList($manager_id): array { - if(empty($manager_id) or !is_numeric($manager_id)) - { + if (empty($manager_id) or !is_numeric($manager_id)) { throw new NotFoundHttpException('Incorrect manager ID'); } $managerEmployeesList = ManagerService::getManagerEmployeesList($manager_id); - if(empty($managerEmployeesList)) { + if (empty($managerEmployeesList)) { throw new NotFoundHttpException('Managers are not assigned or employees are not assigned to him'); } @@ -55,14 +53,13 @@ class ManagerController extends ApiController */ public function actionGetManager($manager_id): array { - if(empty($manager_id) or !is_numeric($manager_id)) - { + if (empty($manager_id) or !is_numeric($manager_id)) { throw new NotFoundHttpException('Incorrect manager ID'); } $manager = ManagerService::getManager($manager_id); - if(empty($manager)) { + if (empty($manager)) { throw new NotFoundHttpException('There is no such manager'); } diff --git a/frontend/modules/api/controllers/TaskController.php b/frontend/modules/api/controllers/TaskController.php index 62749ce..dd9a3ef 100644 --- a/frontend/modules/api/controllers/TaskController.php +++ b/frontend/modules/api/controllers/TaskController.php @@ -31,7 +31,6 @@ class TaskController extends ApiController if ($taskModel->errors) { throw new ServerErrorHttpException(json_encode($taskModel->errors)); } - return $taskModel; } @@ -39,23 +38,19 @@ class TaskController extends ApiController /** * @throws NotFoundHttpException */ - public function actionGetTaskList($project_id = null): array + public function actionGetTaskList($project_id = null): array { $tasks = array(); - if ($project_id) - { - if(empty($project_id) or !is_numeric($project_id)) - { + if ($project_id) { + if (empty($project_id) or !is_numeric($project_id)) { throw new NotFoundHttpException('Incorrect project ID'); } $tasks = TaskService::getTaskListByProject($project_id); - } - else - { + } else { $tasks = TaskService::getTaskList($project_id); } - if(empty($tasks)) { + if (empty($tasks)) { throw new NotFoundHttpException('The project does not exist or there are no tasks for it'); } return $tasks; @@ -66,13 +61,12 @@ class TaskController extends ApiController */ public function actionGetTask($task_id): Task { - if(empty($task_id) or !is_numeric($task_id)) - { + if (empty($task_id) or !is_numeric($task_id)) { throw new NotFoundHttpException('Incorrect task ID'); } $task = TaskService::getTask($task_id); - if(empty($task)) { + if (empty($task)) { throw new NotFoundHttpException('The task does not exist'); } @@ -87,8 +81,7 @@ class TaskController extends ApiController public function actionUpdate(): ?Task { $params = Yii::$app->request->getBodyParams(); - if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id'])) - { + if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id'])) { throw new NotFoundHttpException('The task does not exist'); } diff --git a/frontend/modules/api/controllers/TaskUserController.php b/frontend/modules/api/controllers/TaskUserController.php index 4cdb3eb..60951a8 100644 --- a/frontend/modules/api/controllers/TaskUserController.php +++ b/frontend/modules/api/controllers/TaskUserController.php @@ -9,19 +9,8 @@ use yii\rest\Controller; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; -class TaskUserController extends Controller +class TaskUserController extends ApiController { - public function behaviors(): array - { - $behaviors = parent::behaviors(); - - $behaviors['authenticator']['authMethods'] = [ - HttpBearerAuth::className(), - ]; - - return $behaviors; - } - public function verbs(): array { return [