use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
class WallabagRestController extends FOSRestController
{
- /**
- * @param Entry $entry
- * @param string $tags
- */
- private function assignTagsToEntry(Entry $entry, $tags)
- {
- foreach (explode(',', $tags) as $label) {
- $label = trim($label);
- $tagEntity = $this
- ->getDoctrine()
- ->getRepository('WallabagCoreBundle:Tag')
- ->findOneByLabel($label);
-
- if (is_null($tagEntity)) {
- $tagEntity = new Tag();
- $tagEntity->setLabel($label);
- }
-
- // only add the tag on the entry if the relation doesn't exist
- if (!$entry->getTags()->contains($tagEntity)) {
- $entry->addTag($tagEntity);
- }
- }
- }
-
private function validateAuthentication()
{
if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
$order = $request->query->get('order', 'desc');
$page = (int) $request->query->get('page', 1);
$perPage = (int) $request->query->get('perPage', 30);
- $tags = $request->query->get('tags', []);
$pager = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
$pagerfantaFactory = new PagerfantaFactory('page', 'perPage');
$paginatedCollection = $pagerfantaFactory->createRepresentation(
$pager,
- new Route('api_get_entries', [], $absolute = true)
+ new Route('api_get_entries', [], UrlGeneratorInterface::ABSOLUTE_URL)
);
$json = $this->get('serializer')->serialize($paginatedCollection, 'json');
$tags = $request->request->get('tags', '');
if (!empty($tags)) {
- $this->assignTagsToEntry($entry, $tags);
+ $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
}
$em = $this->getDoctrine()->getManager();
$tags = $request->request->get('tags', '');
if (!empty($tags)) {
- $this->assignTagsToEntry($entry, $tags);
+ $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
}
$em = $this->getDoctrine()->getManager();
$tags = $request->request->get('tags', '');
if (!empty($tags)) {
- $this->assignTagsToEntry($entry, $tags);
+ $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
}
$em = $this->getDoctrine()->getManager();