use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpFoundation\JsonResponse;
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
{
* )
* @return array
*/
- public function getSaltAction($username)
+ public function getSaltAction(Request $request)
{
$user = $this
->getDoctrine()
->getRepository('WallabagCoreBundle:User')
- ->findOneByUsername($username);
+ ->findOneByUsername($request->query->get('username'));
if (is_null($user)) {
throw $this->createNotFoundException();
$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);
}
/**
$json = $this->get('serializer')->serialize($entry->getTags(), 'json');
- return new Response($json, 200, array('application/json'));
+ return new JsonResponse($json, 200);
}
/**
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);
}
}