aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/WallabagRestController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/WallabagRestController.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
index c298d849..f77a3749 100644
--- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php
@@ -13,6 +13,29 @@ use Wallabag\CoreBundle\Service\Extractor;
13class WallabagRestController extends Controller 13class WallabagRestController extends Controller
14{ 14{
15 /** 15 /**
16 * Retrieve salt for a giver user.
17 *
18 * @ApiDoc(
19 * parameters={
20 * {"name"="username", "dataType"="string", "required"=true, "description"="username"}
21 * }
22 * )
23 * @return string
24 */
25 public function getSaltAction($username)
26 {
27 $user = $this
28 ->getDoctrine()
29 ->getRepository('WallabagCoreBundle:User')
30 ->findOneByUsername($username);
31
32 if (is_null($user)) {
33 throw $this->createNotFoundException();
34 }
35
36 return $user->getSalt();
37 }
38 /**
16 * Retrieve all entries. It could be filtered by many options. 39 * Retrieve all entries. It could be filtered by many options.
17 * 40 *
18 * @ApiDoc( 41 * @ApiDoc(
@@ -43,7 +66,7 @@ class WallabagRestController extends Controller
43 $entries = $this 66 $entries = $this
44 ->getDoctrine() 67 ->getDoctrine()
45 ->getRepository('WallabagCoreBundle:Entry') 68 ->getRepository('WallabagCoreBundle:Entry')
46 ->findEntries(1, $isArchived, $isStarred, $isDeleted, $sort, $order); 69 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isDeleted, $sort, $order);
47 70
48 if (!is_array($entries)) { 71 if (!is_array($entries)) {
49 throw $this->createNotFoundException(); 72 throw $this->createNotFoundException();
@@ -85,8 +108,7 @@ class WallabagRestController extends Controller
85 $url = $request->request->get('url'); 108 $url = $request->request->get('url');
86 109
87 $content = Extractor::extract($url); 110 $content = Extractor::extract($url);
88 $entry = new Entry(); 111 $entry = new Entry($this->getUser());
89 $entry->setUserId(1);
90 $entry->setUrl($url); 112 $entry->setUrl($url);
91 $entry->setTitle($request->request->get('title') ?: $content->getTitle()); 113 $entry->setTitle($request->request->get('title') ?: $content->getTitle());
92 $entry->setContent($content->getBody()); 114 $entry->setContent($content->getBody());