/** * Add a delete entry to the audit log. * * @param Events\FormEvent $event */ public function onFormDelete(Events\FormEvent $event) { $form = $event->getForm(); $formId = $form->deletedId; $foci = $this->model->getRepository()->findByForm($formId); if (empty($foci)) { return; } // Rebuild each focus /** @var \MauticPlugin\MauticFocusBundle\Entity\Focus $focus */ foreach ($foci as $focus) { $focus->setForm(null); $focus->setCache($this->model->generateJavascript($focus)); } $this->model->saveEntities($foci); }
/** * Add a delete entry to the audit log. * * @param Events\FormEvent $event */ public function onFormDelete(Events\FormEvent $event) { $form = $event->getForm(); $log = ['bundle' => 'form', 'object' => 'form', 'objectId' => $form->deletedId, 'action' => 'delete', 'details' => ['name' => $form->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()]; $this->auditLogModel->writeToLog($log); }
/** * {@inheritdoc} * * @return bool|FormEvent|void * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null) { if (!$entity instanceof Form) { throw new MethodNotAllowedHttpException(array('Form')); } switch ($action) { case "pre_save": $name = FormEvents::FORM_PRE_SAVE; break; case "post_save": $name = FormEvents::FORM_POST_SAVE; break; case "pre_delete": $name = FormEvents::FORM_PRE_DELETE; break; case "post_delete": $name = FormEvents::FORM_POST_DELETE; break; default: return null; } if ($this->dispatcher->hasListeners($name)) { if (empty($event)) { $event = new FormEvent($entity, $isNew); $event->setEntityManager($this->em); } $this->dispatcher->dispatch($name, $event); return $event; } else { return null; } }
/** * Add a delete entry to the audit log * * @param Events\FormEvent $event */ public function onFormDelete(Events\FormEvent $event) { $form = $event->getForm(); $log = array("bundle" => "form", "object" => "form", "objectId" => $form->deletedId, "action" => "delete", "details" => array('name' => $form->getName()), "ipAddress" => $this->factory->getIpAddressFromRequest()); $this->factory->getModel('core.auditLog')->writeToLog($log); }