get('name'); $data = $this->repository->findAllTagNames($filter); $view = new View($data, 200); $view->getContext()->setGroups(self::GROUPS_COLLECTION); return $this->viewHandler->handle($view); } /** * Creates a new tag */ #[OA\Post(description: 'Creates a new tag and returns it afterwards', responses: [new OA\Response(response: 200, description: 'Returns the new created tag', content: new OA\JsonContent(ref: '#/components/schemas/TagEntity'))])] #[OA\RequestBody(required: true, content: new OA\JsonContent(ref: '#/components/schemas/TagEditForm'))] #[Rest\Post(name: 'post_tag')] #[ApiSecurity(name: 'apiUser')] #[ApiSecurity(name: 'apiToken')] public function postAction(Request $request): Response { if (!$this->isGranted('manage_tag') && !$this->isGranted('create_tag')) { throw $this->createAccessDeniedException('User cannot create tags'); } $tag = new Tag(); $form = $this->createForm(TagApiEditForm::class, $tag); $form->submit($request->request->all()); if ($form->isValid()) { $this->repository->saveTag($tag); $view = new View($tag, 200); $view->getContext()->setGroups(self::GROUPS_ENTITY); return $this->viewHandler->handle($view); } $view = new View($form); $view->getContext()->setGroups(self::GROUPS_FORM); return $this->viewHandler->handle($view); } /** * Delete a tag */ #[IsGranted('delete_tag')] #[OA\Delete(responses: [new OA\Response(response: 204, description: 'HTTP code 204 for a successful delete')])] #[OA\Parameter(name: 'id', in: 'path', description: 'Tag ID to delete', required: true)] #[ApiSecurity(name: 'apiUser')] #[ApiSecurity(name: 'apiToken')] #[Rest\Delete(path: '/{id}', name: 'delete_tag')] public function deleteAction(Tag $tag): Response { $this->repository->deleteTag($tag); $view = new View(null, Response::HTTP_NO_CONTENT); return $this->viewHandler->handle($view); } }