public function delete(DeleteEventArgs $eventArgs) { $document = $eventArgs->getDocument(); $metadata = $eventArgs->getMetadata(); $freezer = $this->getFreezer(); if (!$freezer->getFreezeField($metadata) || !$freezer->isFrozen($document, $metadata)) { return; } // Deletions of frozen models are not allowed. Roll them back $eventArgs->setReject(true); // Raise frozenDeleteDenied $eventArgs->getEventManager()->dispatchEvent(Events::FROZEN_DELETE_DENIED, new AccessControlEventArgs($document, 'delete')); }
public function delete(DeleteEventArgs $eventArgs) { //Check delete permsisions $document = $eventArgs->getDocument(); if ($this->getAccessController()->areAllowed([Actions::DELETE], $eventArgs->getMetadata(), $document)->getAllowed()) { return; } $eventArgs->setReject(true); $eventArgs->getEventManager()->dispatchEvent(AccessControlEvents::DELETE_DENIED, new EventArgs($document, Actions::DELETE)); }