aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Twig/WallabagExtension.php')
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index a305c53f..351172c4 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -3,9 +3,9 @@
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
6use Symfony\Component\Translation\TranslatorInterface;
6use Wallabag\CoreBundle\Repository\EntryRepository; 7use Wallabag\CoreBundle\Repository\EntryRepository;
7use Wallabag\CoreBundle\Repository\TagRepository; 8use Wallabag\CoreBundle\Repository\TagRepository;
8use Symfony\Component\Translation\TranslatorInterface;
9 9
10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface 10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
11{ 11{
@@ -33,11 +33,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
33 33
34 public function getFunctions() 34 public function getFunctions()
35 { 35 {
36 return array( 36 return [
37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), 37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']),
38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), 38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']),
39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), 39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']),
40 ); 40 ];
41 } 41 }
42 42
43 public function removeWww($url) 43 public function removeWww($url)
@@ -64,19 +64,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
64 case 'starred': 64 case 'starred':
65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId()); 65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId());
66 break; 66 break;
67
68 case 'archive': 67 case 'archive':
69 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId()); 68 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId());
70 break; 69 break;
71
72 case 'unread': 70 case 'unread':
73 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId()); 71 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId());
74 break; 72 break;
75
76 case 'all': 73 case 'all':
77 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); 74 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
78 break; 75 break;
79
80 default: 76 default:
81 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 77 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
82 } 78 }
@@ -139,7 +135,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
139 $nbDays = (int) $interval->format('%a') ?: 1; 135 $nbDays = (int) $interval->format('%a') ?: 1;
140 136
141 // force setlocale for date translation 137 // force setlocale for date translation
142 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage()))); 138 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()) . '_' . strtoupper(strtolower($user->getConfig()->getLanguage())));
143 139
144 return $this->translator->trans('footer.stats', [ 140 return $this->translator->trans('footer.stats', [
145 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()), 141 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()),