X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FWallabagRestController.php;h=27d11da5ec158c931f614186d51777a75f73fa3b;hb=f59f45d74093e92656f9717c8c5f4e37c56d2173;hp=1df18247235ddb11f9c86d6f87f8addb86e6e5ef;hpb=29c4517f7a8ed08239e5bee3d6c3fa823a83d102;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 1df18247..27d11da5 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -7,11 +7,34 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Wallabag\CoreBundle\Entity\Entry; -use Wallabag\CoreBundle\Entity\Tags; +use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Service\Extractor; class WallabagRestController extends Controller { + /** + * Retrieve salt for a giver user. + * + * @ApiDoc( + * parameters={ + * {"name"="username", "dataType"="string", "required"=true, "description"="username"} + * } + * ) + * @return string + */ + public function getSaltAction($username) + { + $user = $this + ->getDoctrine() + ->getRepository('WallabagCoreBundle:User') + ->findOneByUsername($username); + + if (is_null($user)) { + throw $this->createNotFoundException(); + } + + return $user->getSalt(); + } /** * Retrieve all entries. It could be filtered by many options. * @@ -43,9 +66,9 @@ class WallabagRestController extends Controller $entries = $this ->getDoctrine() ->getRepository('WallabagCoreBundle:Entry') - ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); + ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isDeleted, $sort, $order); - if (!is_array($entries)) { + if (!($entries)) { throw $this->createNotFoundException(); } @@ -85,8 +108,7 @@ class WallabagRestController extends Controller $url = $request->request->get('url'); $content = Extractor::extract($url); - $entry = new Entry(); - $entry->setUserId(1); + $entry = new Entry($this->getUser()); $entry->setUrl($url); $entry->setTitle($request->request->get('title') ?: $content->getTitle()); $entry->setContent($content->getBody()); @@ -206,7 +228,7 @@ class WallabagRestController extends Controller * } * ) */ - public function deleteEntriesTagsAction(Entry $entry, Tags $tag) + public function deleteEntriesTagsAction(Entry $entry, Tag $tag) { } @@ -229,7 +251,7 @@ class WallabagRestController extends Controller * } * ) */ - public function getTagAction(Tags $tag) + public function getTagAction(Tag $tag) { } @@ -242,7 +264,7 @@ class WallabagRestController extends Controller * } * ) */ - public function deleteTagAction(Tags $tag) + public function deleteTagAction(Tag $tag) { } }