コード例 #1
0
 /**
  * @param $params
  */
 public function __invoke($params)
 {
     $serviceManager = ServiceManager::getServiceManager();
     $service = new CategoryService();
     $service->setServiceManager($serviceManager);
     $serviceManager->register(CategoryService::SERVICE_ID, $service);
 }
コード例 #2
0
 /**
  * Test CategoryService#getItemCategories
  */
 public function testGetItemCategories()
 {
     $fooClass = new RdfClass('foo');
     $eligibleProp1 = $this->prophesize('\\core_kernel_classes_Property');
     $eligibleProp1->getWidget()->willReturn(new RdfResource(CategoryService::$supportedWidgetUris[0]));
     $eligibleProp1->getUri()->willReturn('p1');
     $eligibleProp2 = $this->prophesize('\\core_kernel_classes_Property');
     $eligibleProp2->getWidget()->willReturn(new RdfResource(CategoryService::$supportedWidgetUris[2]));
     $eligibleProp2->getUri()->willReturn('p2');
     $p2Value = $this->prophesize('\\core_kernel_classes_Resource');
     $p2Value->getLabel()->willReturn('Yeah Moo');
     $item = $this->prophesize('\\core_kernel_classes_Resource');
     $item->getPropertiesValues(Argument::any())->willReturn(['p1' => ['Foo', 'Yo _Bar '], 'p2' => [$p2Value->reveal()]]);
     $item->getTypes()->willReturn([$fooClass]);
     $itemService = $this->prophesize('\\taoItems_models_classes_ItemsService');
     $itemService->getClazzProperties($fooClass, Argument::any())->willReturn(['p1' => $eligibleProp1->reveal(), 'p2' => $eligibleProp2->reveal()]);
     $categoryService = new CategoryService();
     $categoryService->setItemService($itemService->reveal());
     $categories = $categoryService->getItemCategories($item->reveal());
     $this->assertEquals(3, count($categories), "We have 3 categories");
     $this->assertEquals('foo', $categories[0], "The category matches");
     $this->assertEquals('yo-bar', $categories[1], "The category matches");
     $this->assertEquals('yeah-moo', $categories[2], "The category matches");
 }
コード例 #3
0
 /**
  *
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     //migrate from 2.6 to 2.6.1
     if ($this->isVersion('2.6')) {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_6_1.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             ${$this}->setVerion('2.6.1');
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($this->isVersion('2.6.1')) {
         // double check
         $index = new core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOItem.rdf#ItemContentIndex');
         $default = $index->getPropertyValues(new core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAO.rdf#IndexDefaultSearch'));
         if (count($default) == 0) {
             //no default search set, import
             $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_6_2.rdf';
             $adapter = new tao_helpers_data_GenerisAdapterRdf();
             if ($adapter->import($file)) {
                 $this->setVerion('2.6.2');
             } else {
                 common_Logger::w('Import failed for ' . $file);
             }
         } else {
             common_Logger::w('Defautl Search already set');
             ${$this}->setVerion('2.6.2');
         }
     }
     if ($this->isVersion('2.6.2')) {
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_6_1.rdf');
         OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_6_2.rdf');
         $this->setVerion('2.6.3');
     }
     if ($this->isVersion('2.6.3')) {
         // update user roles
         $class = new core_kernel_classes_Class(CLASS_TAO_USER);
         $itemManagers = $class->searchInstances(array(PROPERTY_USER_ROLES => 'http://www.tao.lu/Ontologies/TAOItem.rdf#ItemsManagerRole'), array('recursive' => true, 'like' => false));
         foreach ($itemManagers as $user) {
             $user->setPropertyValue(new core_kernel_classes_Property(PROPERTY_USER_ROLES), ItemAuthorRole::INSTANCE_URI);
         }
         $this->setVerion('2.6.4');
     }
     if ($this->isBetween('2.6.4', '2.8')) {
         $this->setVersion('2.8');
     }
     // fix itemModelLabelProp
     if ($this->isVersion('2.8')) {
         $fakeProperty = new core_kernel_classes_Property('itemModelLabel');
         $iterator = new core_kernel_classes_ResourceIterator(array(taoItems_models_classes_ItemsService::singleton()->getRootClass()));
         foreach ($iterator as $resource) {
             $resource->removePropertyValues($fakeProperty);
         }
         $this->setVersion('2.8.1');
     }
     $this->skip('2.8.1', '2.14.0');
     if ($this->isVersion('2.14.0')) {
         OntologyUpdater::syncModels();
         AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#AbstractItemAuthor', 'taoItems_actions_ItemContent'));
         $this->setVersion('2.15.0');
     }
     $this->skip('2.15.0', '2.22.3');
     if ($this->isVersion('2.22.3')) {
         OntologyUpdater::syncModels();
         $categoryService = new CategoryService();
         $categoryService->setServiceManager($this->getServiceManager());
         $this->getServiceManager()->register(CategoryService::SERVICE_ID, $categoryService);
         $this->setVersion('2.23.0');
     }
     if ($this->isVersion('2.23.0')) {
         OntologyUpdater::syncModels();
         $this->setVersion('2.24.0');
     }
     $this->skip('2.24.0', '2.24.1');
 }