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


PHP PersistenceManagerInterface::createQueryForType方法代码示例

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


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

示例1: getOptions

 /**
  */
 public function getOptions()
 {
     $classSchema = $this->reflectionService->getClassSchema($this->getRelationClass());
     if ($classSchema->getRepositoryClassName() !== NULL) {
         $repository = $this->objectManager->get($classSchema->getRepositoryClassName());
         $query = call_user_func(array($repository, $this->settings['QueryMethod']));
     } else {
         $query = $this->persistenceManager->createQueryForType($this->getRelationClass());
     }
     $options = $query->execute()->toArray();
     if ($this->settings['LabelPath'] !== NULL) {
         $options = array();
         foreach ($query->execute() as $option) {
             $identifier = $this->persistenceManager->getIdentifierByObject($option);
             $label = ObjectAccess::getPropertyPath($option, $this->settings['LabelPath']);
             $options[$identifier] = $label;
         }
     }
     if ($this->settings['EmptyOption'] !== NULL) {
         $newOptions = array('' => $this->settings['EmptyOption']);
         foreach ($options as $key => $value) {
             $newOptions[$key] = $value;
         }
         $options = $newOptions;
     }
     return $options;
 }
开发者ID:mia3,项目名称:expose,代码行数:29,代码来源:RelationOptionsProvider.php

示例2: findObjectByIdentityProperties

 /**
  * Finds an object from the repository by searching for its identity properties.
  *
  * @param array $identityProperties Property names and values to search for
  * @param string $type The object type to look for
  * @return object Either the object matching the identity or NULL if no object was found
  * @throws DuplicateObjectException if more than one object was found
  */
 protected function findObjectByIdentityProperties(array $identityProperties, $type)
 {
     $query = $this->persistenceManager->createQueryForType($type);
     $classSchema = $this->reflectionService->getClassSchema($type);
     $equals = array();
     foreach ($classSchema->getIdentityProperties() as $propertyName => $propertyType) {
         if (isset($identityProperties[$propertyName])) {
             if ($propertyType === 'string') {
                 $equals[] = $query->equals($propertyName, $identityProperties[$propertyName], FALSE);
             } else {
                 $equals[] = $query->equals($propertyName, $identityProperties[$propertyName]);
             }
         }
     }
     if (count($equals) === 1) {
         $constraint = current($equals);
     } else {
         $constraint = $query->logicalAnd(current($equals), next($equals));
         while (($equal = next($equals)) !== FALSE) {
             $constraint = $query->logicalAnd($constraint, $equal);
         }
     }
     $objects = $query->matching($constraint)->execute();
     $numberOfResults = $objects->count();
     if ($numberOfResults === 1) {
         return $objects->getFirst();
     } elseif ($numberOfResults === 0) {
         return NULL;
     } else {
         throw new DuplicateObjectException('More than one object was returned for the given identity, this is a constraint violation.', 1259612399);
     }
 }
开发者ID:sakona999,项目名称:flow-login,代码行数:40,代码来源:PersistentObjectConverter.php

示例3: createQuery

 /**
  * Returns a query for objects of this repository
  *
  * @return \TYPO3\Flow\Persistence\QueryInterface
  * @api
  */
 public function createQuery()
 {
     $query = $this->persistenceManager->createQueryForType($this->entityClassName);
     if ($this->defaultOrderings !== array()) {
         $query->setOrderings($this->defaultOrderings);
     }
     return $query;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:14,代码来源:Repository.php

示例4: getModificationsNeededStatesAndIdentifiers

 /**
  * @param Client $client
  * @param string $className
  *
  * @return array
  */
 protected function getModificationsNeededStatesAndIdentifiers(Client $client, $className)
 {
     $query = $this->persistenceManager->createQueryForType($className);
     $states = array(ObjectIndexer::ACTION_TYPE_CREATE => array(), ObjectIndexer::ACTION_TYPE_UPDATE => array(), ObjectIndexer::ACTION_TYPE_DELETE => array());
     foreach ($query->execute() as $object) {
         $state = $this->objectIndexer->objectIndexActionRequired($object, $client);
         $states[$state][] = $this->persistenceManager->getIdentifierByObject($object);
     }
     return $states;
 }
开发者ID:robertlemke,项目名称:Flowpack.ElasticSearch,代码行数:16,代码来源:IndexCommandController.php

示例5: isValid

 /**
  * Checks if the given value is a unique entity depending on it's identity properties or
  * custom configured identity properties.
  *
  * @param mixed $value The value that should be validated
  * @return void
  * @throws \TYPO3\Flow\Validation\Exception\InvalidValidationOptionsException
  * @api
  */
 protected function isValid($value)
 {
     if (!is_object($value)) {
         throw new InvalidValidationOptionsException('The value supplied for the UniqueEntityValidator must be an object.', 1358454270);
     }
     $classSchema = $this->reflectionService->getClassSchema($value);
     if ($classSchema === NULL || $classSchema->getModelType() !== \TYPO3\Flow\Reflection\ClassSchema::MODELTYPE_ENTITY) {
         throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must be an entity.', 1358454284);
     }
     if ($this->options['identityProperties'] !== NULL) {
         $identityProperties = $this->options['identityProperties'];
         foreach ($identityProperties as $propertyName) {
             if ($classSchema->hasProperty($propertyName) === FALSE) {
                 throw new InvalidValidationOptionsException(sprintf('The custom identity property name "%s" supplied for the UniqueEntityValidator does not exists in "%s".', $propertyName, $classSchema->getClassName()), 1358960500);
             }
         }
     } else {
         $identityProperties = array_keys($classSchema->getIdentityProperties());
     }
     if (count($identityProperties) === 0) {
         throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must have at least one identity property.', 1358459831);
     }
     $identifierProperties = $this->reflectionService->getPropertyNamesByAnnotation($classSchema->getClassName(), 'Doctrine\\ORM\\Mapping\\Id');
     if (count($identifierProperties) > 1) {
         throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must only have one identifier property @ORM\\Id.', 1358501745);
     }
     $identifierPropertyName = count($identifierProperties) > 0 ? array_shift($identifierProperties) : 'Persistence_Object_Identifier';
     $query = $this->persistenceManager->createQueryForType($classSchema->getClassName());
     $constraints = array($query->logicalNot($query->equals($identifierPropertyName, $this->persistenceManager->getIdentifierByObject($value))));
     foreach ($identityProperties as $propertyName) {
         $constraints[] = $query->equals($propertyName, ObjectAccess::getProperty($value, $propertyName));
     }
     if ($query->matching($query->logicalAnd($constraints))->count() > 0) {
         $this->addError('Another entity with the same unique identifiers already exists', 1355785874);
     }
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:45,代码来源:UniqueEntityValidator.php

示例6: createQuery

 /**
  * @return QueryInterface
  */
 protected function createQuery()
 {
     return $this->persistenceManager->createQueryForType($this->projectionClassName);
 }
开发者ID:flow2lab,项目名称:eventsourcing,代码行数:7,代码来源:AbstractModelProjector.php


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