本文整理汇总了PHP中core_kernel_classes_Class::setPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::setPropertyValue方法的具体用法?PHP core_kernel_classes_Class::setPropertyValue怎么用?PHP core_kernel_classes_Class::setPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::setPropertyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importProperties
/**
* Import the properties of the resource
*
* @param core_kernel_classes_Resource $resource
* @param array $propertiesValues
* @param array $map
* @param core_kernel_classes_Class $class
* @return common_report_Report
*/
private function importProperties(core_kernel_classes_Resource $resource, $propertiesValues, $map, $class)
{
if (isset($propertiesValues[RDF_TYPE])) {
// assuming single Type
if (count($propertiesValues[RDF_TYPE]) > 1) {
return new common_report_Report(common_report_Report::TYPE_ERROR, __('Resource not imported due to multiple types'));
} else {
foreach ($propertiesValues[RDF_TYPE] as $k => $v) {
$classType = isset($map[$v['value']]) ? new core_kernel_classes_Class($map[$v['value']]) : $class;
//$resource->setType($classType);
$classType->createInstance(null, null, $resource->getUri());
}
}
unset($propertiesValues[RDF_TYPE]);
}
if (isset($propertiesValues[RDFS_SUBCLASSOF])) {
$resource = new core_kernel_classes_Class($resource);
// assuming single subclass
if (isset($propertiesValues[RDF_TYPE]) && count($propertiesValues[RDF_TYPE]) > 1) {
return new common_report_Report(common_report_Report::TYPE_ERROR, __('Resource not imported due to multiple super classes'));
}
foreach ($propertiesValues[RDFS_SUBCLASSOF] as $k => $v) {
$classSup = isset($map[$v['value']]) ? new core_kernel_classes_Class($map[$v['value']]) : $class;
$resource->setSubClassOf($classSup);
}
unset($propertiesValues[RDFS_SUBCLASSOF]);
}
foreach ($propertiesValues as $prop => $values) {
$property = new core_kernel_classes_Property(isset($map[$prop]) ? $map[$prop] : $prop);
foreach ($values as $k => $v) {
$value = isset($map[$v['value']]) ? $map[$v['value']] : $v['value'];
if (isset($v['lang'])) {
$resource->setPropertyValueByLg($property, $value, $v['lang']);
} else {
$resource->setPropertyValue($property, $value);
}
}
}
$msg = $resource instanceof core_kernel_classes_Class ? __('Successfully imported class "%s"', $resource->getLabel()) : __('Successfully imported "%s"', $resource->getLabel());
return new common_report_Report(common_report_Report::TYPE_SUCCESS, $msg, $resource);
}
示例2: testEditMediaInstance
public function testEditMediaInstance()
{
$fileTmp = dirname(__DIR__) . '/sample/Italy.png';
$this->initializeMock($fileTmp);
$this->fileManagerMock->expects($this->once())->method('deleteFile')->with('MyLink')->willReturn(true);
$lang = 'EN-en';
$instanceUri = 'http://myFancyDomain.com/myGreatInstanceUri';
$instance = new \core_kernel_classes_Class($instanceUri);
$instance->setPropertyValue(new \core_kernel_classes_Property(MEDIA_LINK), 'MyLink');
$this->mediaService->editMediaInstance($fileTmp, $instanceUri, $lang);
$this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong');
// remove what has been done
$inst = new \core_kernel_classes_Resource($instanceUri);
$inst->delete();
}