/** * Add a delete entry to the audit log. * * @param WebhookEvent $event */ public function onWebhookDelete(WebhookEvent $event) { $webhook = $event->getWebhook(); $log = ['bundle' => 'webhook', 'object' => 'webhook', 'objectId' => $event->getWebhook()->deletedId, 'action' => 'delete', 'details' => ['name' => $webhook->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()]; $this->auditLogModel->writeToLog($log); }
/** * Add a delete entry to the audit log * * @param WebhookEvent $event */ public function onWebhookDelete(WebhookEvent $event) { $webhook = $event->getWebhook(); $log = array("bundle" => "webhook", "object" => "webhook", "objectId" => $event->getWebhook()->deletedId, "action" => "delete", "details" => array('name' => $webhook->getName()), "ipAddress" => $this->factory->getIpAddressFromRequest()); $this->factory->getModel('core.auditLog')->writeToLog($log); }
/** * {@inheritdoc} * * @param $action * @param $event * @param $entity * @param $isNew * * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ protected function dispatchEvent($action, &$entity, $isNew = false, SymfonyEvent $event = null) { if (!$entity instanceof Webhook) { throw new MethodNotAllowedHttpException(['Webhook'], 'Entity must be of class Webhook()'); } switch ($action) { case 'pre_save': $name = WebhookEvents::WEBHOOK_PRE_SAVE; break; case 'post_save': $name = WebhookEvents::WEBHOOK_POST_SAVE; break; case 'pre_delete': $name = WebhookEvents::WEBHOOK_PRE_DELETE; break; case 'post_delete': $name = WebhookEvents::WEBHOOK_POST_DELETE; break; default: return null; } if ($this->dispatcher->hasListeners($name)) { if (empty($event)) { $event = new WebhookEvent($entity, $isNew); $event->setEntityManager($this->em); } $this->dispatcher->dispatch($name, $event); return $event; } else { return null; } }