/**
  * Flush in notification
  */
 protected function flushNotification(Announcement $entity, $title = "Nouvelle Action", $criticity = "success")
 {
     $notification = $this->dm->getRepository('BackBundle:Notifications')->findOneByAid($entity->getId());
     if (!$notification) {
         $notification = new Notifications();
     }
     $notification->setAid($entity->getId());
     $notification->setTitle($title);
     $notification->setObject($entity->getTitle());
     $notification->setCriticity($criticity);
     $notification->setAuthor($entity->getUser());
     $this->dm->persist($notification);
     $this->dm->flush();
     $redis = new \Redis();
     $redis->connect('127.0.0.1', '6379');
     $emitter = new Emitter($redis);
     $now = new \DateTime('now');
     $emitter->emit('notification', ['title' => $title, 'date' => $now->format('Y-m-d H:i:s'), 'author' => $entity->getUser()->getPseudo(), 'objet' => $entity->getTitle(), 'criticity' => $criticity]);
 }