From 22a4b20ed04a9c709fbbe3e254ad8b2d7757a38b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 12 May 2017 15:02:32 +0200 Subject: First draft for notifications Signed-off-by: Thomas Citharel --- src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Wallabag/CoreBundle/Twig/WallabagExtension.php') 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 @@ namespace Wallabag\CoreBundle\Twig; +use Doctrine\Common\Collections\Collection; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Wallabag\CoreBundle\Notifications\NotificationInterface; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; use Symfony\Component\Translation\TranslatorInterface; @@ -28,6 +30,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa { return [ new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']), + new \Twig_SimpleFilter('unread_notif', [$this, 'unreadNotif']), ]; } @@ -45,6 +48,13 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return preg_replace('/^www\./i', '', $url); } + public function unreadNotif(Collection $notifs) + { + return $notifs->filter(function(NotificationInterface $notif) { + return !$notif->isRead(); + }); + } + /** * Return number of entries depending of the type (unread, archive, starred or all). * -- cgit v1.2.3