示例#1
0
 /**
  * Add a delete entry to the audit log
  *
  * @param Events\EmailEvent $event
  */
 public function onEmailDelete(Events\EmailEvent $event)
 {
     $email = $event->getEmail();
     $log = array("bundle" => "email", "object" => "email", "objectId" => $email->deletedId, "action" => "delete", "details" => array('name' => $email->getName()), "ipAddress" => $this->factory->getIpAddressFromRequest());
     $this->factory->getModel('core.auditLog')->writeToLog($log);
 }
示例#2
0
 /**
  * {@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 Email) {
         throw new MethodNotAllowedHttpException(array('Email'));
     }
     switch ($action) {
         case "pre_save":
             $name = EmailEvents::EMAIL_PRE_SAVE;
             break;
         case "post_save":
             $name = EmailEvents::EMAIL_POST_SAVE;
             break;
         case "pre_delete":
             $name = EmailEvents::EMAIL_PRE_DELETE;
             break;
         case "post_delete":
             $name = EmailEvents::EMAIL_POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new EmailEvent($entity, $isNew);
             $event->setEntityManager($this->em);
         }
         $this->dispatcher->dispatch($name, $event);
         return $event;
     } else {
         return null;
     }
 }
示例#3
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\EmailEvent $event
  */
 public function onEmailDelete(Events\EmailEvent $event)
 {
     $email = $event->getEmail();
     $log = ['bundle' => 'email', 'object' => 'email', 'objectId' => $email->deletedId, 'action' => 'delete', 'details' => ['name' => $email->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }