/**
  * Send a notification
  *
  * @param Notification $notif
  * @param bool         $tryCompile
  * @return bool
  */
 public function send(Notification $notif, $tryCompile = false)
 {
     /** @var $em EntityManager */
     $em = $this->doctrine->getManager();
     if (!$notif->getIsSuper() && $tryCompile) {
         $oldDate = new \DateTime();
         $oldDate->setTime(date('h') - 1, date('i'), date('s'));
         $oldNotif = $em->createQueryBuilder()->select('n')->from('EtuCoreBundle:Notification', 'n')->where('n.createdAt > :oldDate')->andWhere('n.isSuper = 0')->andWhere('n.helper = :helper')->andWhere('n.entityType = :entityType')->andWhere('n.entityId = :entityId')->setParameter('oldDate', $oldDate)->setParameter('helper', $notif->getHelper())->setParameter('entityType', $notif->getEntityType())->setParameter('entityId', $notif->getEntityId())->setMaxResults(1)->getQuery()->getOneOrNullResult();
         if ($oldNotif instanceof Notification) {
             $oldNotif->setEntities(array_merge($oldNotif->getEntities(), $notif->getEntities()));
             $oldNotif->setCreatedAt($notif->getDate());
             $em->persist($oldNotif);
         } else {
             $em->persist($notif);
         }
     } else {
         $em->persist($notif);
     }
     $em->flush();
     return true;
 }