diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Twig')
-rw-r--r-- | src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 10 |
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 | ||
3 | namespace Wallabag\CoreBundle\Twig; | 3 | namespace Wallabag\CoreBundle\Twig; |
4 | 4 | ||
5 | use Doctrine\Common\Collections\Collection; | ||
5 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | 6 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
7 | use Wallabag\CoreBundle\Notifications\NotificationInterface; | ||
6 | use Wallabag\CoreBundle\Repository\EntryRepository; | 8 | use Wallabag\CoreBundle\Repository\EntryRepository; |
7 | use Wallabag\CoreBundle\Repository\TagRepository; | 9 | use Wallabag\CoreBundle\Repository\TagRepository; |
8 | use Symfony\Component\Translation\TranslatorInterface; | 10 | use 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 | * |