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.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index a305c53f..ad224b6c 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -2,7 +2,9 @@
2 2
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Doctrine\Common\Collections\Collection;
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Wallabag\CoreBundle\Notifications\NotificationInterface;
6use Wallabag\CoreBundle\Repository\EntryRepository; 8use Wallabag\CoreBundle\Repository\EntryRepository;
7use Wallabag\CoreBundle\Repository\TagRepository; 9use Wallabag\CoreBundle\Repository\TagRepository;
8use Symfony\Component\Translation\TranslatorInterface; 10use Symfony\Component\Translation\TranslatorInterface;
@@ -28,6 +30,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
28 { 30 {
29 return [ 31 return [
30 new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']), 32 new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
33 new \Twig_SimpleFilter('unread_notif', [$this, 'unreadNotif']),
31 ]; 34 ];
32 } 35 }
33 36
@@ -45,6 +48,13 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
45 return preg_replace('/^www\./i', '', $url); 48 return preg_replace('/^www\./i', '', $url);
46 } 49 }
47 50
51 public function unreadNotif(Collection $notifs)
52 {
53 return $notifs->filter(function(NotificationInterface $notif) {
54 return !$notif->isRead();
55 });
56 }
57
48 /** 58 /**
49 * Return number of entries depending of the type (unread, archive, starred or all). 59 * Return number of entries depending of the type (unread, archive, starred or all).
50 * 60 *