*/ class NodeCopiedListener implements IEventListener { private $attachmentService; public function __construct(AttachmentService $attachmentService) { $this->attachmentService = $attachmentService; } public function handle(Event $event): void { if (!$event instanceof NodeCopiedEvent) { return; } $source = $event->getSource(); $target = $event->getTarget(); if ($source instanceof File && $source->getMimeType() === 'text/markdown' && $target instanceof File && $target->getMimeType() === 'text/markdown' ) { $fileIdMapping = $this->attachmentService->copyAttachments($source, $target); $target->unlock(ILockingProvider::LOCK_SHARED); AttachmentService::replaceAttachmentFolderId($source, $target); AttachmentService::replaceAttachmentFileIds($target, $fileIdMapping); $target->lock(ILockingProvider::LOCK_SHARED); } } }