protected static function cloneFile($fileUri) { \common_Logger::i('clone file ' . $fileUri); $file = new \core_kernel_versioning_File($fileUri); $newFile = $file->getRepository()->spawnFile($file->getAbsolutePath(), $file->getLabel(), function ($originalName) { return md5($originalName); }); return $newFile->getUri(); }
/** * * @author Lionel Lecaque, lionel@taotesting.com * @param core_kernel_classes_Resource $source * @param core_kernel_classes_Resource $destination * @param core_kernel_classes_Property $property */ protected function cloneInstanceProperty(core_kernel_classes_Resource $source, core_kernel_classes_Resource $destination, core_kernel_classes_Property $property) { $range = $property->getRange(); // Avoid doublons, the RDF TYPE property will be set by the implementation layer if ($property->getUri() != RDF_TYPE) { foreach ($source->getPropertyValuesCollection($property)->getIterator() as $propertyValue) { if (!is_null($range) && $range->getUri() == CLASS_GENERIS_FILE) { $file = new core_kernel_versioning_File($propertyValue->getUri()); $newFile = $file->getRepository()->spawnFile($file->getAbsolutePath(), $file->getLabel()); $destination->setPropertyValue($property, $newFile); } else { $destination->setPropertyValue($property, $propertyValue); } } } }