From 843dbe5195d157d4c3094aed5f63d960dd789060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 30 Jan 2015 09:05:54 +0100 Subject: create entry via API --- .../CoreBundle/Controller/WallabagRestController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') 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; use Symfony\Component\HttpFoundation\Request; use Wallabag\CoreBundle\Entity\Entries; use Wallabag\CoreBundle\Entity\Tags; +use Wallabag\CoreBundle\Service\Extractor; class WallabagRestController extends Controller { @@ -79,9 +80,24 @@ class WallabagRestController extends Controller * } * ) */ - public function postEntriesAction() + public function postEntriesAction(Request $request) { + //TODO la récup ne marche + //TODO gérer si on passe le titre + //TODO gérer si on passe les tags + //TODO ne pas avoir du code comme ça qui doit se trouver dans le Repository + $entry = new Entries(); + $entry->setUserId(1); + $content = Extractor::extract($request->request->get('url')); + $entry->setTitle($content->getTitle()); + $entry->setContent($content->getBody()); + + $em = $this->getDoctrine()->getManager(); + $em->persist($entry); + $em->flush(); + + return $entry; } /** -- cgit v1.2.3