getContainer()->getPermissionsService()->currentUserCanWrite(Entities::SERVICES)) { throw new AccessDeniedException('You are not allowed to update bookable category.'); } $result = new CommandResult(); $category = CategoryFactory::create($command->getFields()); if (!$category instanceof Category) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not update bookable category.'); return $result; } /** @var CategoryRepository $categoryRepository */ $categoryRepository = $this->container->get('domain.bookable.category.repository'); if ($categoryRepository->update($command->getArg('id'), $category)) { $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully updated bookable category.'); $result->setData([ Entities::CATEGORY => $category->toArray() ]); } return $result; } }