getResult(); if (!$resource instanceof core_kernel_classes_Resource) { throw new Exception('Unit is not a resource'); } if ($this->getSharedStimulusResourceSpecification()->isSatisfiedBy($resource)) { $fileLink = $resource->getUniquePropertyValue($this->getProperty(MediaService::PROPERTY_LINK)); $fileLink = $fileLink instanceof core_kernel_classes_Resource ? $fileLink->getUri() : (string)$fileLink; $fileSource = $this->getFileManager()->getFileStream($fileLink); $content = $fileSource instanceof File ? $fileSource->read() : $fileSource->getContents(); $elementIds = $this->getSharedStimulusExtractor()->extractMediaIdentifiers($content); $this->getMediaRelationUpdateService()->updateByTargetId($resource->getUri(), $elementIds); } } private function getSharedStimulusExtractor(): SharedStimulusMediaExtractor { return $this->getServiceLocator()->get(SharedStimulusMediaExtractor::class); } private function getFileManager(): FileManagement { return $this->getServiceLocator()->get(FileManagement::SERVICE_ID); } private function getMediaRelationUpdateService(): MediaRelationUpdateService { return $this->getServiceLocator()->get(MediaRelationUpdateService::class); } private function getSharedStimulusResourceSpecification(): SharedStimulusResourceSpecification { return $this->getServiceLocator()->get(SharedStimulusResourceSpecification::class); } }