/**
  * Add a delete entry to the audit log.
  *
  * @param NotificationEvent $event
  */
 public function onDelete(NotificationEvent $event)
 {
     $entity = $event->getNotification();
     $log = ['bundle' => 'notification', 'object' => 'notification', 'objectId' => $entity->getId(), 'action' => 'delete', 'details' => ['name' => $entity->getName()]];
     $this->auditLogModel->writeToLog($log);
 }
 /**
  * {@inheritdoc}
  *
  * @param $action
  * @param $event
  * @param $entity
  * @param $isNew
  *
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
 {
     if (!$entity instanceof Notification) {
         throw new MethodNotAllowedHttpException(array('Notification'));
     }
     switch ($action) {
         case "pre_save":
             $name = NotificationEvents::NOTIFICATION_PRE_SAVE;
             break;
         case "post_save":
             $name = NotificationEvents::NOTIFICATION_POST_SAVE;
             break;
         case "pre_delete":
             $name = NotificationEvents::NOTIFICATION_PRE_DELETE;
             break;
         case "post_delete":
             $name = NotificationEvents::NOTIFICATION_POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new NotificationEvent($entity, $isNew);
             $event->setEntityManager($this->em);
         }
         $this->dispatcher->dispatch($name, $event);
         return $event;
     } else {
         return null;
     }
 }