]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/WallabagRestController.php
Adding new user
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / WallabagRestController.php
index 75e5204e4fab4876e544b95dfbab678eac90485d..e9cd8c93922da75efa0d4b93f0e6822d85d7dc21 100644 (file)
@@ -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)
     {
     }
 }