getOntology()->getResource($query->getId()); return new SharedStimulus( $query->getId(), $this->getPropertyValue($resource, MediaService::PROPERTY_ALT_TEXT), $this->getPropertyValue($resource, MediaService::PROPERTY_LANGUAGE), $this->getContent($resource) ); } /** * @throws common_Exception * @throws core_kernel_classes_EmptyProperty */ private function getContent(core_kernel_classes_Resource $resource): string { $link = $this->getPropertyValue($resource, MediaService::PROPERTY_LINK); $link = $this->getFileSourceUnserializer()->unserialize($link); return (string)$this->getFileManagement()->getFileStream($link); } /** * @throws common_Exception * @throws core_kernel_classes_EmptyProperty */ private function getPropertyValue(core_kernel_classes_Resource $resource, string $uri) { $propertyValue = $resource->getUniquePropertyValue($resource->getProperty($uri)); if ($propertyValue instanceof core_kernel_classes_Resource) { return $propertyValue->getUri(); } if ($propertyValue instanceof core_kernel_classes_Literal) { return (string)$propertyValue; } } private function getFileManagement(): FileManagement { return $this->getServiceLocator()->get(FileManagement::SERVICE_ID); } private function getOntology(): Ontology { return $this->getServiceLocator()->get(Ontology::SERVICE_ID); } private function getFileSourceUnserializer(): FileSourceUnserializer { return $this->getServiceLocator()->get(FileSourceUnserializer::class); } }