當前位置: 首頁>>代碼示例>>PHP>>正文


PHP core_kernel_classes_Class::setPropertyValue方法代碼示例

本文整理匯總了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);
 }
開發者ID:oat-sa,項目名稱:tao-core,代碼行數:50,代碼來源:class.RdfImporter.php

示例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();
 }
開發者ID:nagyist,項目名稱:extension-tao-mediamanager,代碼行數:15,代碼來源:MediaServiceTest.php


注:本文中的core_kernel_classes_Class::setPropertyValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。