namespace Wallabag\ApiBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
->getRepository('WallabagCoreBundle:Tag')
->findAllTags($this->getUser()->getId());
- $json = $this->get('serializer')->serialize($tags, 'json');
+ $json = $this->get('jms_serializer')->serialize($tags, 'json');
return (new JsonResponse())->setJson($json);
}
/**
- * Permanently remove one tag from **every** entry.
+ * Permanently remove one tag from **every** entry by passing the Tag label.
*
* @ApiDoc(
* requirements={
public function deleteTagLabelAction(Request $request)
{
$this->validateAuthentication();
- $label = $request->request->get('tag', '');
+ $label = $request->get('tag', '');
$tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label);
$this->cleanOrphanTag($tag);
- $json = $this->get('serializer')->serialize($tag, 'json');
+ $json = $this->get('jms_serializer')->serialize($tag, 'json');
return (new JsonResponse())->setJson($json);
}
{
$this->validateAuthentication();
- $tagsLabels = $request->request->get('tags', '');
+ $tagsLabels = $request->get('tags', '');
$tags = [];
$this->cleanOrphanTag($tags);
- $json = $this->get('serializer')->serialize($tags, 'json');
+ $json = $this->get('jms_serializer')->serialize($tags, 'json');
return (new JsonResponse())->setJson($json);
}
/**
- * Permanently remove one tag from **every** entry.
+ * Permanently remove one tag from **every** entry by passing the Tag ID.
*
* @ApiDoc(
* requirements={
$this->cleanOrphanTag($tag);
- $json = $this->get('serializer')->serialize($tag, 'json');
+ $json = $this->get('jms_serializer')->serialize($tag, 'json');
return (new JsonResponse())->setJson($json);
}
*/
private function cleanOrphanTag($tags)
{
- if (!is_array($tags)) {
+ if (!\is_array($tags)) {
$tags = [$tags];
}
$em = $this->getDoctrine()->getManager();
foreach ($tags as $tag) {
- if (count($tag->getEntries()) === 0) {
+ if (0 === \count($tag->getEntries())) {
$em->remove($tag);
}
}