/**
  * Add a delete entry to the audit log.
  *
  * @param Events\DynamicContentEvent $event
  */
 public function onDelete(Events\DynamicContentEvent $event)
 {
     $entity = $event->getDynamicContent();
     $log = ['bundle' => 'dynamicContent', 'object' => 'dynamicContent', 'objectId' => $entity->getId(), 'action' => 'delete', 'details' => ['name' => $entity->getName()]];
     $this->auditLogModel->writeToLog($log);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  *
  * @param $action
  * @param $entity
  * @param $isNew
  * @param $event
  *
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
 {
     if (!$entity instanceof DynamicContent) {
         throw new MethodNotAllowedHttpException(['Dynamic Content']);
     }
     switch ($action) {
         case "pre_save":
             $name = DynamicContentEvents::PRE_SAVE;
             break;
         case "post_save":
             $name = DynamicContentEvents::POST_SAVE;
             break;
         case "pre_delete":
             $name = DynamicContentEvents::PRE_DELETE;
             break;
         case "post_delete":
             $name = DynamicContentEvents::POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new DynamicContentEvent($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\DynamicContentEvent $event
  */
 public function onDelete(Events\DynamicContentEvent $event)
 {
     $entity = $event->getDynamicContent();
     $log = ["bundle" => "dynamicContent", "object" => "dynamicContent", "objectId" => $entity->getId(), "action" => "delete", "details" => ['name' => $entity->getName()]];
     $this->factory->getModel('core.auditLog')->writeToLog($log);
 }