->findOneByLabel($label);
if (is_null($tagEntity)) {
- $tagEntity = new Tag($this->getUser());
+ $tagEntity = new Tag();
$tagEntity->setLabel($label);
}
private function validateAuthentication()
{
- if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
+ if (false === $this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
throw new AccessDeniedException();
}
}
$perPage = (int) $request->query->get('perPage', 30);
$tags = $request->query->get('tags', []);
- $pager = $this
- ->getDoctrine()
+ $pager = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Entry')
->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order);
public function getTagsAction()
{
$this->validateAuthentication();
- $json = $this->get('serializer')->serialize($this->getUser()->getTags(), 'json');
+
+ $tags = $this->getDoctrine()
+ ->getRepository('WallabagCoreBundle:Tag')
+ ->findAllTags($this->getUser()->getId());
+
+ $json = $this->get('serializer')->serialize($tags, 'json');
return $this->renderJsonResponse($json);
}
public function deleteTagAction(Tag $tag)
{
$this->validateAuthentication();
- $this->validateUserAccess($tag->getUser()->getId());
+
+ $this->getDoctrine()
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->removeTag($this->getUser()->getId(), $tag);
$em = $this->getDoctrine()->getManager();
$em->remove($tag);
*/
private function validateUserAccess($requestUserId)
{
- $user = $this->get('security.context')->getToken()->getUser();
+ $user = $this->get('security.token_storage')->getToken()->getUser();
if ($requestUserId != $user->getId()) {
throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
}