@DI\Observe("delete_file")

@param DeleteResourceEvent $event
334570
public function onDelete(DeleteResourceEvent $event)
    {
        $workspaceCode = $event->getResource()
            ->getResourceNode()
            ->getWorkspace()
            ->getCode();
        $pathName = $this->container->getParameter('claroline.param.files_directory') .
            DIRECTORY_SEPARATOR .
            $event->getResource()->getHashName();

        if (file_exists($pathName)) {
            $event->setFiles(array($pathName));
        }

        $event->stopPropagation();
    }
361
public function handleRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();
        $this->documentRegistry->deregisterDocument($document);
    }
1297151
public function onDelete(Delete $event)
    {
        if ($this->isDependent()) {
            $class = $this->getRelatedEntity();
            /** @var Entity $entity */
            $entity = new $class();
            $fkField = $this->getForeignKey();
            $pmk = $event->getTarget()->getPrimaryKey();
            $sql = Sql::createSql($entity->getAdapter())
                ->delete($entity->getTableName())
                ->where(
                    ["{$fkField} = :id" => [':id' => $event->getTarget()->$pmk]]
                );

            $sql->execute();
        }
    }
1305987
public function deleteFromCache(EventInterface $event) {
        $request = $event->getRequest();
        $cacheDir = $this->getCacheDir($request->getUser(), $request->getImageIdentifier());

        if (is_dir($cacheDir)) {
            $this->rmdir($cacheDir);
        }
    }
554205
protected function _deleteFile(Event $event) {
		try {
			$this->_beforeDeleteFile($event);
			$entity = $event->getData('entity');
			$path = $this->pathBuilder()->fullPath($entity);

			if ($this->getStorageAdapter($entity->adapter)->delete($path)) {
				$event->result = true;
				$event->setData('path', $path);
				$event->setData('entity', $entity);
				$this->_afterDeleteFile($event);

				return true;
			}
		} catch (\Exception $e) {
			$this->log($e->getMessage(), LogLevel::ERROR, ['scope' => ['storage']]);
			throw new StorageException($e->getMessage(), $e->getCode(), $e);
		}

		return false;
	}
655913
public function onCreate(CreateResourceEvent $event)
    {
        $request = $this->container->get('request');
        $form = $this->formFactory->create(new DirectoryType(), new Directory());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $published = $form->get('published')->getData();
            $event->setPublished($published);
            $event->setResources(array($form->getData()));
            $event->stopPropagation();

            return;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Resource:createForm.html.twig',
            array(
                'form' => $form->createView(),
                'resourceType' => 'directory'
            )
        );
        $event->setErrorFormContent($content);
        $event->stopPropagation();
    }
1115571
public function deleteShortUrl(EventInterface $event) {
        $database = $event->getDatabase();
        $request = $event->getRequest();
        $user = $request->getUser();
        $imageIdentifier = $request->getImageIdentifier();
        $shortUrlId = $request->getRoute()->get('shortUrlId');

        if (!$params = $database->getShortUrlParams($shortUrlId)) {
            throw new ResourceException('ShortURL not found', 404);
        }

        if ($params['user'] !== $user || $params['imageIdentifier'] !== $imageIdentifier) {
            throw new ResourceException('ShortURL not found', 404);
        }

        $database->deleteShortUrls(
            $user,
            $imageIdentifier,
            $shortUrlId
        );

        $model = new ArrayModel();
        $model->setData([
            'id' => $shortUrlId,
        ]);

        $event->getResponse()->setModel($model);
    }
196474
public function deindexRemovedDocument(RemoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof StructureBehavior) {
            return;
        }

        if (!$document instanceof WorkflowStageBehavior) {
            $this->searchManager->deindex($document);
        } else {
            $workflowStage = $document->getWorkflowStage();

            foreach (WorkflowStage::$stages as $stage) {
                $document->setWorkflowStage($stage);
                $this->searchManager->deindex($document);
            }

            $document->setWorkflowStage($workflowStage);
        }
    }
524253
public function delete(ViewSource $source, string $className)
    {
        try {
            $this->files->delete($this->getKey($source, $className));
        } catch (\Throwable $e) {
        }
    }
502234
def on_deleted(self, event):
        
        logger.debug("file removed: %s", event.src_path)
        name = self.file_name(event)

        self.on_delete(self.target_class, name)
566361
public function preDelete(DeleteEvent $event)
    {
        $announcement = $event->getObject();
        $send = $this->om->getRepository(AnnouncementSend::class)->findBy(['announcement' => $announcement]);

        foreach ($send as $el) {
            $this->om->remove($el);
        }

        // delete scheduled task is any
        $this->manager->unscheduleMessage($announcement);

        $this->eventDispatcher->dispatch(
            'log',
            'Claroline\\AnnouncementBundle\\Event\\Log\\LogAnnouncementDeleteEvent',
            [$announcement->getAggregate(), $announcement]
        );
    }
346976
public function onSitemapNodeDelete(TreeNodeEvent $event)
    {
        $node = $event->getNode();
        if (TextNodeInterface::NODE_TYPE === $node->getType()) {
            $this->nodeHandler->onDeleteNode($node);
        }
    }
1149237
public function handlePreRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();

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

        $event = $this->getDeleteEvent($document);
        $this->deleteEvents[spl_object_hash($document)] = $event;
        $this->eventDispatcher->dispatch(
            ContentEvents::NODE_PRE_DELETE,
            $event
        );
    }
1324723
public function beforeDelete(Delete $event)
    {
        $parent = $event->getEntity()->{$this->propertyName};
        if ($parent instanceof EntityInterface) {
            $parent->delete();
        }
    }
583685
public function onDelete(DeleteResourceEvent $event)
    {
        /** @var Exercise $exercise */
        $exercise = $event->getResource();

        $deletable = $this->exerciseManager->isDeletable($exercise);
        if (!$deletable) {
            // If papers, the Exercise is not completely removed
            $event->enableSoftDelete();
        }

        $event->stopPropagation();
    }
225540
public function preDelete(DeleteEvent $event)
    {
        $aggregate = $event->getObject();

        foreach ($aggregate->getAnnouncements() as $announcement) {
            $this->crud->delete($announcement);
        }
    }
826453
public function delete(MessageDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) {
            $message
                ->setDispatcher($dispatcher)
                ->delete()
            ;

            $event->setMessage($message);
        }
    }