]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Twig/WallabagExtension.php
First draft for notifications
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Twig / WallabagExtension.php
index a305c53fc1819a50733746578b9bd30792ab66ef..ad224b6c3342d5065f7737c1f1cb6786369b081c 100644 (file)
@@ -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).
      *