当前位置: 首页>>代码示例>>PHP>>正文


PHP core_kernel_classes_Class::searchInstances方法代码示例

本文整理汇总了PHP中core_kernel_classes_Class::searchInstances方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Class::searchInstances方法的具体用法?PHP core_kernel_classes_Class::searchInstances怎么用?PHP core_kernel_classes_Class::searchInstances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_kernel_classes_Class的用法示例。


在下文中一共展示了core_kernel_classes_Class::searchInstances方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mapLTIRole2TaoRole

 /**
  * Maps a fuly qualified or abbreviated lti role
  * to an existing tao role
  * 
  * @param string $role
  * @throws common_Exception
  * @throws common_exception_Error
  * @return core_kernel_classes_Resource the tao role or null
  */
 public static function mapLTIRole2TaoRole($role)
 {
     $taoRole = null;
     if (filter_var($role, FILTER_VALIDATE_URL)) {
         // url found
         $taoRole = new core_kernel_classes_Resource($role);
     } else {
         // if not fully qualified prepend LIS context role NS
         if (strtolower(substr($role, 0, 4)) !== 'urn:') {
             $role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role;
         }
         list($prefix, $nid, $nss) = explode(':', $role, 3);
         if ($nid != 'lti') {
             common_Logger::w('Non LTI URN ' . $role . ' passed via LTI');
         }
         $urn = 'urn:' . strtolower($nid) . ':' . $nss;
         // search for fitting role
         $class = new core_kernel_classes_Class(CLASS_LTI_ROLES);
         $cand = $class->searchInstances(array(PROPERTY_LTI_ROLES_URN => $urn));
         if (count($cand) > 1) {
             throw new common_exception_Error('Multiple instances share the URN ' . $urn);
         }
         if (count($cand) == 1) {
             $taoRole = current($cand);
         } else {
             common_Logger::w('Unknown LTI role with urn: ' . $urn);
         }
     }
     if (!is_null($taoRole) && $taoRole->exists()) {
         return $taoRole->getUri();
     } else {
         return null;
     }
 }
开发者ID:nagyist,项目名称:extension-tao-lti,代码行数:43,代码来源:class.LtiUtils.php

示例2: authenticate

 /**
  * (non-PHPdoc)
  * @see common_user_auth_Adapter::authenticate()
  */
 public function authenticate()
 {
     $userClass = new core_kernel_classes_Class(CLASS_GENERIS_USER);
     $filters = array(PROPERTY_USER_LOGIN => $this->username);
     $options = array('like' => false, 'recursive' => true);
     $users = $userClass->searchInstances($filters, $options);
     if (count($users) > 1) {
         // Multiple users matching
         throw new common_exception_InconsistentData("Multiple Users found with the same login '" . $this->username . "'.");
     }
     if (empty($users)) {
         // fake code execution to prevent timing attacks
         $label = new core_kernel_classes_Property(RDFS_LABEL);
         $hash = $label->getUniquePropertyValue($label);
         if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) {
             throw new core_kernel_users_InvalidLoginException();
         }
         // should never happen, added for integrity
         throw new core_kernel_users_InvalidLoginException();
     }
     $userResource = current($users);
     $hash = $userResource->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_USER_PASSWORD));
     if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) {
         throw new core_kernel_users_InvalidLoginException();
     }
     return new core_kernel_users_GenerisUser($userResource);
 }
开发者ID:nagyist,项目名称:generis,代码行数:31,代码来源:class.AuthAdapter.php

示例3: getPreviousSteps

 /**
  * Short description of method getPreviousSteps
  *
  * @access public
  * @author Joel Bout, <joel.bout@tudor.lu>
  * @param  Resource step
  * @return array
  */
 public function getPreviousSteps(core_kernel_classes_Resource $step)
 {
     $returnValue = array();
     $stepClass = new core_kernel_classes_Class(CLASS_STEP);
     $returnValue = $stepClass->searchInstances(array(PROPERTY_STEP_NEXT => $step), array('like' => false, 'recursive' => true));
     return (array) $returnValue;
 }
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:15,代码来源:class.StepService.php

示例4: getAllByModel

 /**
  * Get items of a specific model
  * @param string|core_kernel_classes_Resource $itemModel - the item model URI
  * @return core_kernel_classes_Resource[] the found items
  */
 public function getAllByModel($itemModel)
 {
     if (!empty($itemModel)) {
         $uri = $itemModel instanceof core_kernel_classes_Resource ? $itemModel->getUri() : $itemModel;
         return $this->itemClass->searchInstances(array($this->itemModelProperty->getUri() => $uri), array('recursive' => true));
     }
     return array();
 }
开发者ID:oat-sa,项目名称:extension-tao-item,代码行数:13,代码来源:class.ItemsService.php

示例5: findParallelFromActivityBackward

 public function findParallelFromActivityBackward(core_kernel_classes_Resource $activity)
 {
     $returnValue = null;
     //put the activity being searched in an array to prevent searching from it again in case of back connection
     $this->checkedActivities[] = $activity->getUri();
     $connectorClass = new core_kernel_classes_Class(CLASS_CONNECTORS);
     $cardinalityClass = new core_kernel_classes_Class(CLASS_ACTIVITYCARDINALITY);
     $activityCardinalities = $cardinalityClass->searchInstances(array(PROPERTY_STEP_NEXT => $activity->getUri()), array('like' => false));
     //note: count()>1 only
     $nextActivities = array_merge(array($activity->getUri()), array_keys($activityCardinalities));
     $previousConnectors = $connectorClass->searchInstances(array(PROPERTY_STEP_NEXT => $nextActivities), array('like' => false));
     //note: count()>1 only
     foreach ($previousConnectors as $connector) {
         if (in_array($connector->getUri(), array_keys($this->checkedConnectors))) {
             continue;
         } else {
             $this->checkedConnectors[$connector->getUri()] = $connector;
         }
         //get the type of the connector:
         $connectorType = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TYPE));
         if ($connectorType instanceof core_kernel_classes_Resource) {
             switch ($connectorType->getUri()) {
                 case INSTANCE_TYPEOFCONNECTORS_PARALLEL:
                     //parallel connector found:
                     if ($this->jump == 0) {
                         return $returnValue = $connector;
                     } else {
                         $this->jump--;
                     }
                     break;
                 case INSTANCE_TYPEOFCONNECTORS_JOIN:
                     //increment the class attribute $this->jump
                     $this->jump++;
             }
         }
         //if the wanted parallel connector has not be found (i.e. no value returned so far):
         //get the previousActivityCollection and recursively execute the same function ON ONLY ONE of the previous branches (there would be several branches only in the case of a join, otherwise it should be one anyway:
         $previousActivity = $connector->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE));
         //Note: the use of the property activity reference allow to jump to the "main" (in case of a join connector and successive conditionnal connectors) directly
         //if the previousActivity happens to have already been checked, jump it
         if (in_array($previousActivity->getUri(), $this->checkedActivities)) {
             continue;
         } else {
             $parallelConnector = $this->findParallelFromActivityBackward($previousActivity);
             if ($parallelConnector instanceof core_kernel_classes_Resource) {
                 //found it:
                 if ($this->jump != 0) {
                     throw new Exception('parallel connector returned while the "jump value" is not null (' . $this->jump . ')');
                 }
                 return $returnValue = $parallelConnector;
             }
         }
     }
     return $returnValue;
     //null
 }
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:56,代码来源:class.ProcessFlow.php

示例6: getUserExecutions

 /**
  * (non-PHPdoc)
  * @see taoDelivery_models_classes_execution_Service::getUserExecutions()
  */
 public function getUserExecutions(core_kernel_classes_Resource $compiled, $userUri)
 {
     $executionClass = new core_kernel_classes_Class(CLASS_DELVIERYEXECUTION);
     $instances = $executionClass->searchInstances(array(PROPERTY_DELVIERYEXECUTION_SUBJECT => $userUri, PROPERTY_DELVIERYEXECUTION_DELIVERY => $compiled->getUri()), array('like' => false));
     $deliveryExecutions = array();
     foreach ($instances as $resource) {
         $deliveryExecutions[] = new taoDelivery_models_classes_execution_OntologyDeliveryExecution($resource->getUri());
     }
     return $deliveryExecutions;
 }
开发者ID:nagyist,项目名称:extension-tao-delivery,代码行数:14,代码来源:class.OntologyService.php

示例7: getFileSources

 /**
  * returns a list of active FileSources
  *
  * @access public
  * @author Joel Bout, <joel.bout@tudor.lu>
  * @return array
  * @deprecated
  */
 public static function getFileSources()
 {
     $classRepository = new core_kernel_classes_Class(CLASS_GENERIS_VERSIONEDREPOSITORY);
     $resources = $classRepository->searchInstances(array(PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED => GENERIS_TRUE), array('like' => false));
     $fileSystems = array();
     foreach ($resources as $resource) {
         $fileSystems[] = new core_kernel_fileSystem_FileSystem($resource);
     }
     return $fileSystems;
 }
开发者ID:nagyist,项目名称:generis,代码行数:18,代码来源:class.FileSource.php

示例8: getServiceDefinition

 /**
  * Short description of method getServiceDefinition
  *
  * @access public
  * @author Joel Bout, <joel.bout@tudor.lu>
  * @param  string url
  * @return core_kernel_classes_Resource
  */
 public static function getServiceDefinition($url)
 {
     $returnValue = null;
     $serviceClass = new core_kernel_classes_Class(CLASS_SUPPORTSERVICES);
     $services = $serviceClass->searchInstances(array(PROPERTY_SUPPORTSERVICES_URL => $url), array('like' => false, 'recursive' => 1000));
     if (count($services)) {
         $service = array_pop($services);
         if ($service instanceof core_kernel_classes_Resource) {
             $returnValue = $service;
         }
     }
     return $returnValue;
 }
开发者ID:nagyist,项目名称:extension-tao-wfengine,代码行数:21,代码来源:class.ProcessUtil.php

示例9: findOauthConsumerResource

 /**
  * Helper function to find the OauthConsumer RDF Resource
  *
  * @access public
  * @author Joel Bout, <joel@taotesting.com>
  * @param  string consumer_key
  * @return core_kernel_classes_Resource
  */
 public function findOauthConsumerResource($consumer_key)
 {
     $returnValue = null;
     $class = new core_kernel_classes_Class(CLASS_OAUTH_CONSUMER);
     $instances = $class->searchInstances(array(PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
     if (count($instances) == 0) {
         throw new tao_models_classes_oauth_Exception('No Credentials for consumer key ' . $consumer_key);
     }
     if (count($instances) > 1) {
         throw new tao_models_classes_oauth_Exception('Multiple Credentials for consumer key ' . $consumer_key);
     }
     $returnValue = current($instances);
     return $returnValue;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:22,代码来源:class.DataStore.php

示例10: update

 /**
  * 
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $currentVersion = $initialVersion;
     //migrate from 2.6 to 2.6.1
     if ($currentVersion == '2.6') {
         $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'indexation_2_6_1.rdf';
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         if ($adapter->import($file)) {
             $currentVersion = '2.6.1';
         } else {
             common_Logger::w('Import failed for ' . $file);
         }
     }
     if ($currentVersion == '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)) {
                 $currentVersion = '2.6.2';
             } else {
                 common_Logger::w('Import failed for ' . $file);
             }
         } else {
             common_Logger::w('Defautl Search already set');
             $currentVersion = '2.6.2';
         }
     }
     if ($currentVersion == '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');
         $currentVersion = '2.6.3';
     }
     if ($currentVersion == '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);
         }
         $currentVersion = '2.6.4';
     }
     return $currentVersion;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:52,代码来源:class.Updater.php

示例11: lookup

 public function lookup(array $metadataValues)
 {
     $lookup = false;
     foreach ($metadataValues as $metadataValue) {
         $path = $metadataValue->getPath();
         $expectedPath = array(RDFS_LABEL);
         if ($path === $expectedPath) {
             // Check for such a value in database...
             $prop = new \core_kernel_classes_Property(RDFS_LABEL);
             $class = new \core_kernel_classes_Class(RDFS_CLASS);
             $instances = $class->searchInstances(array($prop->getUri() => $metadataValue->getValue()), array('like' => false, 'recursive' => true));
             if (count($instances) > 0) {
                 $lookup = new \core_kernel_classes_Class(reset($instances));
                 break;
             }
         }
     }
     return $lookup;
 }
开发者ID:nagyist,项目名称:extension-tao-itemqti,代码行数:19,代码来源:LabelClassLookup.php

示例12: run

 public function run()
 {
     common_ext_ExtensionsManager::singleton()->getExtensionById('taoTests');
     common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');
     $ds = DIRECTORY_SEPARATOR;
     // 1. Find all the tests that have the QTI Test Model.
     $testClass = new core_kernel_classes_Class(TAO_TEST_CLASS);
     $qtiTests = $testClass->searchInstances(array(PROPERTY_TEST_TESTMODEL => INSTANCE_TEST_MODEL_QTI), array('recursive' => true, 'like' => false));
     // 2. Find the test definition file for each test.
     $testContentProp = new core_kernel_classes_Property(TEST_TESTCONTENT_PROP);
     foreach ($qtiTests as $qtiTest) {
         $testContentResource = $qtiTest->getOnePropertyValue($testContentProp);
         $testContent = new core_kernel_file_File($testContentResource);
         $qtiTestFilePath = $testContent->getAbsolutePath();
         $this->out("test.xml file found at '{$qtiTestFilePath}'.");
         // 2.1. Create a directory using the current file name.
         $pathinfo = pathinfo($qtiTestFilePath);
         $targetDirPath = $pathinfo['dirname'] . $ds . $pathinfo['filename'];
         if (!@mkdir($targetDirPath)) {
             $this->err("Unable to create QTI Test Content directory at location '{$targetDirPath}'.");
         } else {
             $this->out("QTI Test Content directory created at location '{$targetDirPath}'.");
         }
         // 2.2 Copy test.xml into the newly created directory.
         $qtiTestFileCopyDest = $targetDirPath . $ds . 'tao-qtitest-testdefinition.xml';
         if (!@copy($qtiTestFilePath, $qtiTestFileCopyDest)) {
             $this->err("Unable to copy test.xml file from '{$qtiTestFilePath}' to '{$qtiTestFileCopyDest}'.");
         } else {
             $this->out("test.xml file copied from '{$qtiTestFilePath}' to '{$qtiTestFileCopyDest}'.");
         }
         // 2.3 Update metadata in Knowledge Base.
         $newFileResource = $testContent->getFileSystem()->createFile('', basename($targetDirPath));
         $this->out("New File Resource in ontology refers to '" . $newFileResource->getAbsolutePath() . "'.");
         $qtiTest->removePropertyValues($testContentProp);
         $qtiTest->setPropertyValue($testContentProp, $newFileResource);
         $testContentResource->delete(true);
         if (!@unlink($qtiTestFilePath)) {
             $this->err("Unable to remove old test.xml file located at '{$qtiTestFilePath}'.");
         } else {
             $this->out("Old test.xml file located at '{$qtiTestFilePath}' removed from file system.");
         }
     }
 }
开发者ID:llecaque,项目名称:extension-tao-update,代码行数:43,代码来源:class.MigrateQtiTests.php

示例13: getLtiLinkResource

 /**
  * Returns an resource representing the incoming link
  * 
  * @throws common_exception_Error
  * @return core_kernel_classes_Resource
  */
 public function getLtiLinkResource()
 {
     if (is_null($this->ltiLink)) {
         $class = new core_kernel_classes_Class(CLASS_LTI_INCOMINGLINK);
         $consumer = taoLti_models_classes_LtiService::singleton()->getLtiConsumerResource($this->getLaunchData());
         // search for existing resource
         $instances = $class->searchInstances(array(PROPERTY_LTI_LINK_ID => $this->getLaunchData()->getResourceLinkID(), PROPERTY_LTI_LINK_CONSUMER => $consumer), array('like' => false, 'recursive' => false));
         if (count($instances) > 1) {
             throw new common_exception_Error('Multiple resources for link ' . $this->getLaunchData()->getResourceLinkID());
         }
         if (count($instances) == 1) {
             // use existing link
             $this->ltiLink = current($instances);
         } else {
             // spawn new link
             $this->ltiLink = $class->createInstanceWithProperties(array(PROPERTY_LTI_LINK_ID => $this->getLaunchData()->getResourceLinkID(), PROPERTY_LTI_LINK_CONSUMER => $consumer));
         }
     }
     return $this->ltiLink;
 }
开发者ID:nagyist,项目名称:extension-tao-lti,代码行数:26,代码来源:class.TaoLtiSession.php

示例14: getResumableDeliveries

 /**
  * Get resumable (active) deliveries.
  * @param User $user User instance. If not given then all deliveries will be returned regardless of user URI.
  * @return type
  */
 public function getResumableDeliveries($user = null)
 {
     $deliveryExecutionService = taoDelivery_models_classes_execution_ServiceProxy::singleton();
     if ($user === null) {
         $executionClass = new core_kernel_classes_Class(CLASS_DELVIERYEXECUTION);
         $resources = $executionClass->searchInstances(array(PROPERTY_DELVIERYEXECUTION_STATUS => INSTANCE_DELIVERYEXEC_ACTIVE), array('like' => false));
         $started = array_map(function ($resource) use($deliveryExecutionService) {
             return $deliveryExecutionService->getDeliveryExecution($resource);
         }, $resources);
     } else {
         $started = $deliveryExecutionService->getActiveDeliveryExecutions($user->getIdentifier());
     }
     $resumable = array();
     foreach ($started as $deliveryExecution) {
         $delivery = $deliveryExecution->getDelivery();
         if ($delivery->exists()) {
             $resumable[] = $deliveryExecution;
         }
     }
     return $resumable;
 }
开发者ID:nagyist,项目名称:extension-tao-delivery,代码行数:26,代码来源:class.DeliveryServerService.php

示例15: getUserId

 /**
  * Get common user uri associated to Lti user id
  *
  * @param $id string Identifier of LTI user
  * @param $key string Oauth LTI consumer key
  * @return array|null
  * @throws \common_Exception
  * @throws \tao_models_classes_oauth_Exception
  */
 public function getUserId($id, $key)
 {
     $class = new \core_kernel_classes_Class(CLASS_LTI_USER);
     $dataStore = new \tao_models_classes_oauth_DataStore();
     try {
         /** @var \core_kernel_classes_Resource $consumerResource */
         $consumerResource = $dataStore->findOauthConsumerResource($key);
     } catch (\tao_models_classes_oauth_Exception $e) {
         throw new \common_exception_NotFound($e->getMessage());
     }
     $instances = $class->searchInstances(array(PROPERTY_USER_LTIKEY => $id, PROPERTY_USER_LTICONSUMER => $consumerResource), array('like' => false));
     if (count($instances) > 1) {
         throw new \common_Exception('Multiple user accounts found for user key: ' . $id);
     }
     /** @var \core_kernel_classes_Resource $ltiUser */
     $ltiUser = count($instances) == 1 ? current($instances) : null;
     if (!$ltiUser) {
         return null;
     }
     return array('id' => $ltiUser->getUri());
 }
开发者ID:oat-sa,项目名称:extension-tao-lti,代码行数:30,代码来源:LtiRestApiService.php


注:本文中的core_kernel_classes_Class::searchInstances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。