]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/EntryController.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / EntryController.php
index 2ebb416c654671e1b530f0b518c4d8e02072aa16..377a45ae79da8c3b88b46c84863146683916e50c 100644 (file)
@@ -7,14 +7,13 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\HttpFoundation\Request;
 use Wallabag\CoreBundle\Repository;
 use Wallabag\CoreBundle\Entity\Entries;
-use Wallabag\Wallabag\Tools;
-use Wallabag\Wallabag\Url;
+use Wallabag\CoreBundle\Service\Extractor;
+use Wallabag\CoreBundle\Helper\Url;
 
 class EntryController extends Controller
 {
-
     /**
-     * @param Request $request
+     * @param  Request                                    $request
      * @Route("/new", name="new_entry")
      * @return \Symfony\Component\HttpFoundation\Response
      */
@@ -31,11 +30,12 @@ class EntryController extends Controller
         $form->handleRequest($request);
 
         if ($form->isValid()) {
+            $content = Extractor::extract($entry->getUrl());
 
-            $content = Tools::getPageContent(new Url($entry->getUrl()));
-            var_dump($content);die;
+            $entry->setTitle($content->getTitle());
+            $entry->setContent($content->getBody());
 
-            $em = $this->getDoctrine()->getEntityManager();
+            $em = $this->getDoctrine()->getManager();
             $em->persist($entry);
             $em->flush();
 
@@ -61,6 +61,8 @@ class EntryController extends Controller
     public function showUnreadAction()
     {
         $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+        // TODO don't give the user ID like this
+        // TODO change pagination
         $entries = $repository->findUnreadByUser(1, 0);
 
         return $this->render(
@@ -78,6 +80,8 @@ class EntryController extends Controller
     public function showArchiveAction()
     {
         $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+        // TODO don't give the user ID like this
+        // TODO change pagination
         $entries = $repository->findArchiveByUser(1, 0);
 
         return $this->render(
@@ -95,6 +99,8 @@ class EntryController extends Controller
     public function showStarredAction()
     {
         $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries');
+        // TODO don't give the user ID like this
+        // TODO change pagination
         $entries = $repository->findStarredByUser(1, 0);
 
         return $this->render(
@@ -106,7 +112,7 @@ class EntryController extends Controller
     /**
      * Shows entry content
      *
-     * @param Entries $entry
+     * @param  Entries                                    $entry
      * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view")
      * @return \Symfony\Component\HttpFoundation\Response
      */
@@ -121,8 +127,8 @@ class EntryController extends Controller
     /**
      * Changes read status for an entry
      *
-     * @param Request $request
-     * @param Entries $entry
+     * @param  Request                                            $request
+     * @param  Entries                                            $entry
      * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry")
      * @return \Symfony\Component\HttpFoundation\RedirectResponse
      */
@@ -142,8 +148,8 @@ class EntryController extends Controller
     /**
      * Changes favorite status for an entry
      *
-     * @param Request $request
-     * @param Entries $entry
+     * @param  Request                                            $request
+     * @param  Entries                                            $entry
      * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry")
      * @return \Symfony\Component\HttpFoundation\RedirectResponse
      */
@@ -163,14 +169,14 @@ class EntryController extends Controller
     /**
      * Deletes entry
      *
-     * @param Request $request
-     * @param Entries $entry
+     * @param  Request                                            $request
+     * @param  Entries                                            $entry
      * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry")
      * @return \Symfony\Component\HttpFoundation\RedirectResponse
      */
     public function deleteEntryAction(Request $request, Entries $entry)
     {
-        $em = $this->getDoctrine()->getEntityManager();
+        $em = $this->getDoctrine()->getManager();
         $em->remove($entry);
         $em->flush();