X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FWallabagRestController.php;h=e9cd8c93922da75efa0d4b93f0e6822d85d7dc21;hb=e4977b8a866f84f65f08c55c050a62f40170fdbf;hp=75e5204e4fab4876e544b95dfbab678eac90485d;hpb=d29bfaf139975fae71b73ebb316da4ce2205fc92;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 75e5204e..e9cd8c93 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 array + */ + public function getSaltAction($username) + { + $user = $this + ->getDoctrine() + ->getRepository('WallabagCoreBundle:User') + ->findOneByUsername($username); + + if (is_null($user)) { + throw $this->createNotFoundException(); + } + + return array($user->getSalt() ?: null); + } /** * Retrieve all entries. It could be filtered by many options. * @@ -45,7 +68,7 @@ class WallabagRestController extends Controller ->getRepository('WallabagCoreBundle:Entry') ->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($this->getUser()->getId()); + $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) { } }