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 | |
parent | a8c90c5c1b60d0c258ce56f2a8e382859e70e8d3 (diff) | |
download | wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.tar.gz wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.tar.zst wallabag-843dbe5195d157d4c3094aed5f63d960dd789060.zip |
create entry via API
-rw-r--r-- | composer.lock | 8 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/composer.lock b/composer.lock index 716dea4a..21b67941 100644 --- a/composer.lock +++ b/composer.lock | |||
@@ -2283,12 +2283,12 @@ | |||
2283 | "source": { | 2283 | "source": { |
2284 | "type": "git", | 2284 | "type": "git", |
2285 | "url": "https://github.com/tecnickcom/TCPDF.git", | 2285 | "url": "https://github.com/tecnickcom/TCPDF.git", |
2286 | "reference": "da2fe9359426ca334417549248307f33cd042ace" | 2286 | "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb" |
2287 | }, | 2287 | }, |
2288 | "dist": { | 2288 | "dist": { |
2289 | "type": "zip", | 2289 | "type": "zip", |
2290 | "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/da2fe9359426ca334417549248307f33cd042ace", | 2290 | "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", |
2291 | "reference": "da2fe9359426ca334417549248307f33cd042ace", | 2291 | "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", |
2292 | "shasum": "" | 2292 | "shasum": "" |
2293 | }, | 2293 | }, |
2294 | "require": { | 2294 | "require": { |
@@ -2338,7 +2338,7 @@ | |||
2338 | "pdf417", | 2338 | "pdf417", |
2339 | "qrcode" | 2339 | "qrcode" |
2340 | ], | 2340 | ], |
2341 | "time": "2015-01-24 09:41:10" | 2341 | "time": "2015-01-28 18:51:40" |
2342 | }, | 2342 | }, |
2343 | { | 2343 | { |
2344 | "name": "twig/extensions", | 2344 | "name": "twig/extensions", |
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 | /** |