]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/ExportController.php
EntriesExport: change authors and title when not single entry export
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / ExportController.php
index b9e5a974acede4fc9d5f8cbcce36e3f1561b10c4..9e9dbe49a96f1446411c77e2cfd8ab4c9d37a610 100644 (file)
@@ -7,7 +7,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Entity\Tag;
 
 /**
  * The try/catch can be removed once all formats will be implemented.
@@ -34,6 +33,7 @@ class ExportController extends Controller
             return $this->get('wallabag_core.helper.entries_export')
                 ->setEntries($entry)
                 ->updateTitle('entry')
+                ->updateAuthor('entry')
                 ->exportAs($format);
         } catch (\InvalidArgumentException $e) {
             throw new NotFoundHttpException($e->getMessage());
@@ -56,18 +56,21 @@ class ExportController extends Controller
     public function downloadEntriesAction(Request $request, $format, $category)
     {
         $method = ucfirst($category);
-        $methodBuilder = 'getBuilderFor'.$method.'ByUser';
-        $epository = $this->get('wallabag_core.entry_repository');
+        $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
+        $repository = $this->get('wallabag_core.entry_repository');
+        $title = $method;
 
-        if ($category == 'tag_entries') {
+        if ('tag_entries' === $category) {
             $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
 
-            $entries = $epository->findAllByTagId(
+            $entries = $repository->findAllByTagId(
                 $this->getUser()->getId(),
                 $tag->getId()
             );
+
+            $title = 'Tag ' . $tag->getLabel();
         } else {
-            $entries = $epository
+            $entries = $repository
                 ->$methodBuilder($this->getUser()->getId())
                 ->getQuery()
                 ->getResult();
@@ -76,7 +79,8 @@ class ExportController extends Controller
         try {
             return $this->get('wallabag_core.helper.entries_export')
                 ->setEntries($entries)
-                ->updateTitle($method)
+                ->updateTitle($title)
+                ->updateAuthor($method)
                 ->exportAs($format);
         } catch (\InvalidArgumentException $e) {
             throw new NotFoundHttpException($e->getMessage());