diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-10 08:35:43 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-10 08:35:43 +0100 |
commit | c5e8ba25bb0d6d59b3275480f406b5ce3fa83b75 (patch) | |
tree | 9dc8ec3e6e68547287e1a69a1939530fb78927f8 /src/Wallabag/CoreBundle/Controller | |
parent | 7ffb1e80bff2c54fe3fe4343484d377eda660c3f (diff) | |
download | wallabag-c5e8ba25bb0d6d59b3275480f406b5ce3fa83b75.tar.gz wallabag-c5e8ba25bb0d6d59b3275480f406b5ce3fa83b75.tar.zst wallabag-c5e8ba25bb0d6d59b3275480f406b5ce3fa83b75.zip |
getSalt method
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 75e5204e..96d2529a 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -8,11 +8,35 @@ use Symfony\Component\HttpFoundation\Request; | |||
8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | 8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
9 | use Wallabag\CoreBundle\Entity\Entry; | 9 | use Wallabag\CoreBundle\Entity\Entry; |
10 | use Wallabag\CoreBundle\Entity\Tags; | 10 | use Wallabag\CoreBundle\Entity\Tags; |
11 | use Wallabag\CoreBundle\Entity\User; | ||
11 | use Wallabag\CoreBundle\Service\Extractor; | 12 | use Wallabag\CoreBundle\Service\Extractor; |
12 | 13 | ||
13 | class WallabagRestController extends Controller | 14 | class WallabagRestController extends Controller |
14 | { | 15 | { |
15 | /** | 16 | /** |
17 | * Retrieve salt for a giver user. | ||
18 | * | ||
19 | * @ApiDoc( | ||
20 | * parameters={ | ||
21 | * {"name"="username", "dataType"="string", "required"=true, "description"="username"} | ||
22 | * } | ||
23 | * ) | ||
24 | * @return string | ||
25 | */ | ||
26 | public function getSaltAction($username) | ||
27 | { | ||
28 | $user = $this | ||
29 | ->getDoctrine() | ||
30 | ->getRepository('WallabagCoreBundle:User') | ||
31 | ->findOneByUsername($username); | ||
32 | |||
33 | if (is_null($user)) { | ||
34 | throw $this->createNotFoundException(); | ||
35 | } | ||
36 | |||
37 | return $user->getSalt(); | ||
38 | } | ||
39 | /** | ||
16 | * Retrieve all entries. It could be filtered by many options. | 40 | * Retrieve all entries. It could be filtered by many options. |
17 | * | 41 | * |
18 | * @ApiDoc( | 42 | * @ApiDoc( |
@@ -85,8 +109,7 @@ class WallabagRestController extends Controller | |||
85 | $url = $request->request->get('url'); | 109 | $url = $request->request->get('url'); |
86 | 110 | ||
87 | $content = Extractor::extract($url); | 111 | $content = Extractor::extract($url); |
88 | $entry = new Entry(); | 112 | $entry = new Entry($this->getUser()->getId()); |
89 | $entry->setUserId($this->getUser()->getId()); | ||
90 | $entry->setUrl($url); | 113 | $entry->setUrl($url); |
91 | $entry->setTitle($request->request->get('title') ?: $content->getTitle()); | 114 | $entry->setTitle($request->request->get('title') ?: $content->getTitle()); |
92 | $entry->setContent($content->getBody()); | 115 | $entry->setContent($content->getBody()); |