use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Service\Extractor;
-use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class WallabagRestController extends Controller
{
/**
* Retrieve salt for a giver user.
*
- * @ApiDoc(
- * parameters={
- * {"name"="username", "dataType"="string", "required"=true, "description"="username"}
- * }
- * )
+ * @ApiDoc()
* @return array
*/
public function getSaltAction($username)
$json = $this->get('serializer')->serialize($entries, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
$json = $this->get('serializer')->serialize($entry, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
$entry->setTitle($request->request->get('title') ?: $content->getTitle());
$entry->setContent($content->getBody());
- $this->assignTagsToEntry($entry, $request->request->get('tags', array()));
+ $tags = $request->request->get('tags', '');
+ if (!empty($tags)) {
+ $this->assignTagsToEntry($entry, $tags);
+ }
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$json = $this->get('serializer')->serialize($entry, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
$entry->setStarred($isStarred);
}
- $this->assignTagsToEntry($entry, $request->request->get('tags', array()));
+ $tags = $request->request->get('tags', '');
+ if (!empty($tags)) {
+ $this->assignTagsToEntry($entry, $tags);
+ }
$em = $this->getDoctrine()->getManager();
$em->flush();
- return $entry;
+ $json = $this->get('serializer')->serialize($entry, 'json');
+
+ return new JsonResponse($json, 200);
}
/**
$json = $this->get('serializer')->serialize($entry, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
*/
public function getEntriesTagsAction(Entry $entry)
{
- var_dump($entry->getUser()->getId());
- var_dump($this->getUser()->getId());
if ($entry->getUser()->getId() != $this->getUser()->getId()) {
throw $this->createAccessDeniedException();
}
throw $this->createAccessDeniedException();
}
- $this->assignTagsToEntry($entry, $request->request->get('tags', array()));
+ $tags = $request->request->get('tags', '');
+ if (!empty($tags)) {
+ $this->assignTagsToEntry($entry, $tags);
+ }
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$json = $this->get('serializer')->serialize($entry, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
$json = $this->get('serializer')->serialize($entry, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
{
$json = $this->get('serializer')->serialize($this->getUser()->getTags(), 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
$json = $this->get('serializer')->serialize($tag, 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
}