*/ class BeforeNodeDeletedListener implements IEventListener { private AttachmentService $attachmentService; private DocumentService $documentService; public function __construct(AttachmentService $attachmentService, DocumentService $documentService) { $this->attachmentService = $attachmentService; $this->documentService = $documentService; } public function handle(Event $event): void { if (!$event instanceof BeforeNodeDeletedEvent) { return; } $node = $event->getNode(); if (!$node instanceof File) { return; } if ($node->getMimeType() === 'text/markdown') { $this->attachmentService->deleteAttachments($node); } $this->documentService->resetDocument($node->getId(), true); } }