@DI\Observe("resource.delete")

@param ResourceActionEvent $event
436326
public function delete(ResourceActionEvent $event)
    {
        $options = $event->getOptions();

        if (isset($options['hard']) && is_string($options['hard'])) {
            $hard = 'true' === $options['hard'] ? true : false;
        } else {
            if (isset($options['hard'])) {
                $hard = $options['hard'];
            } else {
                $hard = false;
            }
        }

        $this->manager->delete($event->getResourceNode(), false, !$hard);

        $event->setResponse(
            new JsonResponse(null, 204)
        );
    }
1270285
public function unpublish(ResourceActionEvent $event)
    {
        $nodes = $this->manager->setPublishedStatus([$event->getResourceNode()], false);

        $event->setResponse(
            new JsonResponse($this->serializer->serialize($nodes[0]))
        );
    }
115443
public function onDelete(DeleteResourceEvent $event)
    {
        $hashName = $event->getResource()->getHashName();
        $scormArchiveFile = $this->filePath.DIRECTORY_SEPARATOR.$hashName;
        $scormResourcesPath = $this->scormResourcesPath.$hashName;

        $nbScorm = (int) ($this->scormResourceRepo->getNbScormWithHashName($hashName));

        if (1 === $nbScorm) {
            if (file_exists($scormArchiveFile)) {
                $event->setFiles([$scormArchiveFile]);
            }
            if (file_exists($scormResourcesPath)) {
                try {
                    $this->deleteFiles($scormResourcesPath);
                } catch (\Exception $e) {
                }
            }
        }
        $this->om->remove($event->getResource());
        $event->stopPropagation();
    }
863771
public function delete(Resource $resource)
    {
        $data = $resource->toArray();

        $client = $this->getRepository()->findOneBy(array('id' => $data['id']));
        if (!$client) {
            $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id']));
            throw new NotFoundHttpException($errorMessage);
        }

        $this->entityManager->remove($client);
    }
287508
public function deleteMetadata(EventInterface $event) {
        $request = $event->getRequest();

        $event->getDatabase()->deleteMetadata(
            $request->getUser(),
            $request->getImageIdentifier()
        );

        $event->getDatabase()->setLastModifiedNow(
            $request->getUser(),
            $request->getImageIdentifier()
        );
    }
309838
public function removeResource(ResourceNode $resource)
    {
        if ($this->isLinkedToResource($resource)) {
            $this->resources->removeElement($resource);
            --$this->resourceCount;
        }
    }
339624
public function delete(Resource\ResourceId $resourceId)
    {
        $this->crudRepositoryAdapter->deleteResource($this->resourceType, $resourceId);
    }
741979
public function restore(ResourceActionEvent $event)
    {
        $this->manager->restore($event->getResourceNode());

        $event->setResponse(
            new JsonResponse($this->serializer->serialize($event->getResourceNode()))
        );
    }
535493
public function handleForm(FormEvent $event): void
    {
        $admin = $event->getAdmin();
        $action = $admin->getAction();

        if ('delete' === $action->getName()) {
            if (!$admin->hasForm('delete')) {
                return;
            }
            $form = $admin->getForm('delete');
            $this->handleDeleteForm($event->getRequest(), $form, $admin);
        }
    }
1286271
public static function onRemoveElementFile(Event $event)
    {
        $dispatcher = $event->getDispatcher();
        $application = $dispatcher->getApplication();

        try {
            $content = $event->getEventArgs()->getEntity();
            if (!($content instanceof ElementFile)) {
                return;
            }

            $includePath = array($application->getStorageDir(), $application->getMediaDir());
            if (null !== $application->getBBUserToken()) {
                $includePath[] = $application->getTemporaryDir();
            }

            $filename = $content->path;
            File::resolveFilepath($filename, null, array('include_path' => $includePath));

            @unlink($filename);
        } catch (\Exception $e) {
            $application->warning('Unable to delete file: '.$e->getMessage());
        }
    }
223562
public function handleAction(ActionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if ('clear-clipboard' === ($actionName = $event->getAction()->getName())) {
            $this->clearClipboard($event);
        }

        if (false === $this->checkPermission($event)) {
            $this->clearClipboard($event, false);

            $event->stopPropagation();

            return;
        }

        if ('create' === $actionName
            || 'cut' === $actionName
            || 'copy' === $actionName
            || 'deepcopy' === $actionName
        ) {
            $this->addToClipboard($event);
        }
    }
566706
public function handle(ResourceInterface $resource, RepositoryInterface $repository): void
    {
        try {
            $this->decoratedHandler->handle($resource, $repository);
        } catch (ORMException $exception) {
            throw new DeleteHandlingException();
        }
    }
83676
public function onDelete(DeleteResourceEvent $event)
    {
        $ds = DIRECTORY_SEPARATOR;

        /** @var File $resource */
        $resource = $event->getResource();
        $workspace = $resource->getResourceNode()->getWorkspace();
        $hashName = $resource->getHashName();

        $archiveFile = $this->filesDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;
        $webResourcesPath = $this->uploadDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;

        if (file_exists($archiveFile)) {
            $event->setFiles([$archiveFile]);
        }
        if (file_exists($webResourcesPath)) {
            try {
                $this->deleteFiles($webResourcesPath);
            } catch (\Exception $e) {
            }
        }
        $this->om->remove($resource);
        $event->stopPropagation();
    }
818493
protected function persistResource(ResourceEvent $event)
    {
        $resource = $event->getResource();

        // TODO Validation ?

        try {
            $this->manager->persist($resource);
            $this->manager->flush();
        } catch(DBALException $e) {
            if ($this->debug) {
                throw $e;
            }
            $event->addMessage(new ResourceMessage(
                'ekyna_admin.resource.message.persist.failure',
                ResourceMessage::TYPE_ERROR
            ));
            return $event;
        }

        return $event->addMessage(new ResourceMessage(
            'ekyna_admin.resource.message.persist.success',
            ResourceMessage::TYPE_SUCCESS
        ));
    }
698749
public function handlePostRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$this->supports($document)) {
            return;
        }

        $oid = spl_object_hash($document);
        $event = $this->deleteEvents[$oid];

        $this->eventDispatcher->dispatch(
            ContentEvents::NODE_POST_DELETE,
            $event
        );

        unset($this->deleteEvents[$oid]);
    }
570203
public function onPostDelete(ResourceEventInterface $event)
    {
        $page = $this->getPageFromEvent($event);

        $this->deletePageCache($page);
    }
218366
public function onDelete(GenericDataEvent $event)
    {
        /** @var ResourceNode[] $resources */
        $resources = $event->getData();

        $ids = [];
        foreach ($resources as $resource) {
            $ids[] = $resource->getId();
        }

        $this->manager->removeTaggedObjectsByClassAndIds(ResourceNode::class, $ids);
    }