/** * Add a delete entry to the audit log. * * @param FocusEvent $event */ public function onFocusDelete(FocusEvent $event) { $entity = $event->getFocus(); $log = ['bundle' => 'focus', 'object' => 'focus', 'objectId' => $entity->deletedId, 'action' => 'delete', 'details' => ['name' => $entity->getName()], 'ipAddress' => $this->ipHelper->getIpAddressFromRequest()]; $this->auditLogModel->writeToLog($log); }
/** * {@inheritdoc} * * @return bool|FocusEvent|void * * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null) { if (!$entity instanceof Focus) { throw new MethodNotAllowedHttpException(['Focus']); } switch ($action) { case 'pre_save': $name = FocusEvents::PRE_SAVE; break; case 'post_save': $name = FocusEvents::POST_SAVE; break; case 'pre_delete': $name = FocusEvents::PRE_DELETE; break; case 'post_delete': $name = FocusEvents::POST_DELETE; break; default: return null; } if ($this->dispatcher->hasListeners($name)) { if (empty($event)) { $event = new FocusEvent($entity, $isNew); $event->setEntityManager($this->em); } $this->dispatcher->dispatch($name, $event); return $event; } else { return null; } }