roleAllow(UserRole::CONTRACT_ADMIN); } protected function getParam(): IParam { return $this->param; } protected function run(Request $request): JsonResponse { $param = $this->param; // マネージャー起動 if ($param->role === UserRole::CONTRACT_ADMIN) { if ($this->loginUser()->user()->role === UserRole::SUPER_ADMIN) { $this->manager = new ContractAdminUserManager(); } else { $this->unAuthorizedResponse(); } } else { $this->manager = new LoginUserManager(); } try { $this->transaction->beginTransaction(); $currentContract = $this->loginUser()->getCurrentContract(); if (!$currentContract) { throw new AppCommonException("認証不正"); } $messages = $this->manager->initForCreate($currentContract) ->fill($param->toArray()) ->create(); if (count($messages) !== 0) { $this->transaction->rollBack(); return $this->validateErrorResponse($messages); } $this->transaction->commit(); } catch (Exception $e) { $this->transaction->rollBack(); throw $e; } return $this->successResponse(); } }