diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-01-30 09:05:54 +0100 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2015-01-30 09:05:54 +0100 |
commit | 843dbe5195d157d4c3094aed5f63d960dd789060 (patch) | |
tree | 6bf2d0d67f97444d3c5dde99153cbcccae503eab /src | |
parent | a8c90c5c1b60d0c258ce56f2a8e382859e70e8d3 (diff) | |
download | wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.tar.gz wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.tar.zst wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.zip |
create entry via API
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index eec8d32c..a6c0db37 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php | |||
@@ -8,6 +8,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |||
8 | use Symfony\Component\HttpFoundation\Request; | 8 | use Symfony\Component\HttpFoundation\Request; |
9 | use Wallabag\CoreBundle\Entity\Entries; | 9 | use Wallabag\CoreBundle\Entity\Entries; |
10 | use Wallabag\CoreBundle\Entity\Tags; | 10 | use Wallabag\CoreBundle\Entity\Tags; |
11 | use Wallabag\CoreBundle\Service\Extractor; | ||
11 | 12 | ||
12 | class WallabagRestController extends Controller | 13 | class WallabagRestController extends Controller |
13 | { | 14 | { |
@@ -79,9 +80,24 @@ class WallabagRestController extends Controller | |||
79 | * } | 80 | * } |
80 | * ) | 81 | * ) |
81 | */ | 82 | */ |
82 | public function postEntriesAction() | 83 | public function postEntriesAction(Request $request) |
83 | { | 84 | { |
85 | //TODO la récup ne marche | ||
86 | //TODO gérer si on passe le titre | ||
87 | //TODO gérer si on passe les tags | ||
88 | //TODO ne pas avoir du code comme ça qui doit se trouver dans le Repository | ||
89 | $entry = new Entries(); | ||
90 | $entry->setUserId(1); | ||
91 | $content = Extractor::extract($request->request->get('url')); | ||
84 | 92 | ||
93 | $entry->setTitle($content->getTitle()); | ||
94 | $entry->setContent($content->getBody()); | ||
95 | |||
96 | $em = $this->getDoctrine()->getManager(); | ||
97 | $em->persist($entry); | ||
98 | $em->flush(); | ||
99 | |||
100 | return $entry; | ||
85 | } | 101 | } |
86 | 102 | ||
87 | /** | 103 | /** |