diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 1 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 28 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index e0697ca3..5378486a 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -6,7 +6,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Repository; | ||
10 | use Wallabag\CoreBundle\Service\Extractor; | 9 | use Wallabag\CoreBundle\Service\Extractor; |
11 | use Wallabag\CoreBundle\Helper\Url; | 10 | use Wallabag\CoreBundle\Helper\Url; |
12 | 11 | ||
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 4784cb01..27d11da5 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -13,6 +13,29 @@ use Wallabag\CoreBundle\Service\Extractor; | |||
13 | class WallabagRestController extends Controller | 13 | class 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 (!($entries)) { | 71 | if (!($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()); |