本文整理汇总了PHP中core_kernel_classes_Class::setSubClassOf方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::setSubClassOf方法的具体用法?PHP core_kernel_classes_Class::setSubClassOf怎么用?PHP core_kernel_classes_Class::setSubClassOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Class
的用法示例。
在下文中一共展示了core_kernel_classes_Class::setSubClassOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createSubClass
/**
* Short description of method createSubClass
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param Class clazz
* @param string label
* @param string comment
* @param string uri
* @return core_kernel_classes_Class
*/
public static function createSubClass(core_kernel_classes_Class $clazz, $label = '', $comment = '', $uri = '')
{
$returnValue = null;
$class = new core_kernel_classes_Class(RDFS_CLASS);
$instance = self::createInstance($class, $label, $comment, $uri);
$returnValue = new core_kernel_classes_Class($instance->getUri());
$returnValue->setSubClassOf($clazz);
return $returnValue;
}
示例3: testCreateMediaInstance
public function testCreateMediaInstance()
{
$fileTmp = dirname(__DIR__) . '/sample/Brazil.png';
$this->initializeMock($fileTmp);
$lang = 'EN-en';
$classUri = $this->testClass->getUri();
//clear previous tests
$root = new \core_kernel_classes_Class($classUri);
$link = $this->mediaService->createMediaInstance($fileTmp, $classUri, $lang);
$root = new \core_kernel_classes_Class($classUri);
$instances = $root->getInstances();
/** @var \core_kernel_classes_Resource $instance */
$instance = array_pop($instances);
$thing = $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK));
$linkResult = $thing instanceof \core_kernel_classes_Resource ? $thing->getUri() : (string) $thing;
$this->assertInstanceOf('\\core_kernel_classes_Resource', $instance, 'It should create an instance under the class in parameter');
$this->assertEquals('Brazil.png', $instance->getLabel(), 'The instance label is wrong');
$this->assertInternalType('string', $link, 'The method return should be a string');
$this->assertEquals($instance->getUri(), $link, 'The instance link is wrong');
$this->assertEquals($linkResult, 'MyGreatLink', 'The returned link is wrong');
$this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong');
$root->delete(true);
$root->setSubClassOf($this->mediaService->getRootClass());
}