X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FExportController.php;h=9ff35ff5f403148c0e082a47263a07cd00fb9b96;hb=9f0957b831622ee577fa7d8f92ec0df6f3a8e274;hp=abc3336a412b06b4ddcf942184776a24021f90fe;hpb=f17b89fadce0a8c2280fbe1518d66f20dddce59d;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index abc3336a..9ff35ff5 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -2,12 +2,11 @@ namespace Wallabag\CoreBundle\Controller; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Routing\Annotation\Route; 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,17 +56,21 @@ class ExportController extends Controller public function downloadEntriesAction(Request $request, $format, $category) { $method = ucfirst($category); - $methodBuilder = 'getBuilderFor'.$method.'ByUser'; + $methodBuilder = 'getBuilderFor' . $method . 'ByUser'; + $repository = $this->get('wallabag_core.entry_repository'); + $title = $method; - if ($category == 'tag_entries') { - $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneBySlug($request->query->get('tag')); + if ('tag_entries' === $category) { + $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag')); - $entries = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findAllByTagId($this->getUser()->getId(), $tag->getId()); + $entries = $repository->findAllByTagId( + $this->getUser()->getId(), + $tag->getId() + ); + + $title = 'Tag ' . $tag->getLabel(); } else { - $entries = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') + $entries = $repository ->$methodBuilder($this->getUser()->getId()) ->getQuery() ->getResult(); @@ -75,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());