From 77bb7b92a2ea71178edb03c482db33ddf179857d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 5 Feb 2015 18:05:27 +0100 Subject: we can now set a title to the article when we use POST /api/entries --- src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 55906ce0..eb19f0f5 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -80,17 +80,14 @@ class WallabagRestController extends Controller */ public function postEntriesAction(Request $request) { - //TODO la récup ne marche pas - //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 $url = $request->request->get('url'); $content = Extractor::extract($url); $entry = new Entries(); $entry->setUserId(1); $entry->setUrl($url); - $entry->setTitle($content->getTitle()); + $entry->setTitle(!is_null($request->request->get('title')) ? $request->request->get('title') : $content->getTitle()); $entry->setContent($content->getBody()); $em = $this->getDoctrine()->getManager(); $em->persist($entry); -- cgit v1.2.3 From 9e0fff7cb09879d7545db5d4a15da86426b8a19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 5 Feb 2015 18:19:34 +0100 Subject: simplify code --- src/Wallabag/CoreBundle/Controller/WallabagRestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index eb19f0f5..abbf5437 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -87,7 +87,7 @@ class WallabagRestController extends Controller $entry = new Entries(); $entry->setUserId(1); $entry->setUrl($url); - $entry->setTitle(!is_null($request->request->get('title')) ? $request->request->get('title') : $content->getTitle()); + $entry->setTitle($request->request->get('title') ?: $content->getTitle()); $entry->setContent($content->getBody()); $em = $this->getDoctrine()->getManager(); $em->persist($entry); -- cgit v1.2.3