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


PHP ReflectionService::getClassNameByObject方法代码示例

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


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

示例1: objectToScalar

 public function objectToScalar($object, $path = NULL)
 {
     $className = $this->reflectionService->getClassNameByObject($object);
     $methods = $this->getGetterMethodsForClass($className);
     $result = [];
     foreach ($methods as $key => $methodName) {
         $result[$key] = $object->{$methodName}();
     }
     return $result;
 }
开发者ID:mmolle-nelo,项目名称:flow-resttools,代码行数:10,代码来源:AutoNormalizer.php

示例2: transformObject

 /**
  * Traverses the given object structure in order to transform it into an
  * array structure.
  *
  * @param object $object Object to traverse
  * @param array $configuration Configuration for transforming the given object
  * @param boolean $onlyIdentifier
  * @param boolean $enableSideLoading
  * @return array Object structure as an array
  * @todo implement sideloading
  */
 protected function transformObject($object, array $configuration, $onlyIdentifier = TRUE, $enableSideLoading = TRUE)
 {
     if ($object instanceof \DateTime) {
         return $object->format('Y-m-d\\TH:i:s');
     } elseif ($onlyIdentifier === TRUE) {
         return $this->persistenceManager->getIdentifierByObject($object);
     } else {
         $transformedObject = array('id' => $this->persistenceManager->getIdentifierByObject($object));
         $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
         foreach (ObjectAccess::getGettablePropertyNames($object) as $propertyName) {
             if ($this->isPropertyIgnored($objectName, $propertyName)) {
                 continue;
             }
             $propertyValue = ObjectAccess::getProperty($object, $propertyName);
             if (is_array($propertyValue) || $propertyValue instanceof \ArrayAccess) {
                 $propertyValue = $this->transformValue($propertyValue, array(), TRUE, $enableSideLoading);
                 if ($this->isRelation($objectName, $propertyName)) {
                     $this->addLink($transformedObject, $propertyName, $propertyValue);
                     if ($enableSideLoading === TRUE && !$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Lazy')) {
                         $propertyTags = $this->reflectionService->getPropertyTagValues($objectName, $propertyName, 'var');
                         $propertyObjectType = TypeHandling::parseType($propertyTags[0]);
                         $this->sideLoad($propertyObjectType['elementType'], $propertyValue);
                     }
                     $propertyValue = NULL;
                 } elseif (empty($propertyValue)) {
                     $propertyValue = NULL;
                 }
             } elseif ($this->isSimpleValue($propertyValue)) {
                 if (is_object($propertyValue)) {
                     $propertyValue = $this->transformObject($propertyValue, $configuration, FALSE, $enableSideLoading);
                 }
             } elseif (is_object($propertyValue)) {
                 $propertyObjectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($propertyValue));
                 if (!$this->isObjectIgnored($propertyObjectName)) {
                     $propertyValue = $this->transformObject($propertyValue, $configuration, TRUE, $enableSideLoading);
                     if ($this->isRelation($objectName, $propertyName)) {
                         $this->addLink($transformedObject, $propertyName, $propertyValue);
                         if ($enableSideLoading === TRUE && !$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Lazy')) {
                             $this->sideLoad($propertyObjectName, $propertyValue);
                         }
                         $propertyValue = NULL;
                     } elseif (empty($propertyValue)) {
                         $propertyValue = NULL;
                     }
                 }
             }
             if ($propertyValue !== NULL) {
                 if (is_object($propertyValue)) {
                     $propertyObjectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($propertyValue));
                     if (!$this->isObjectIgnored($propertyObjectName)) {
                         $transformedObject[$propertyName] = $propertyValue;
                     }
                 } else {
                     $transformedObject[$propertyName] = $propertyValue;
                 }
             }
         }
         return $transformedObject;
     }
 }
开发者ID:putheakhem,项目名称:Radmiraal.Emberjs,代码行数:71,代码来源:JsonApiSerializer.php

示例3: getIndexTypeForObject

 /**
  * Returns the ElasticSearch type for a specific object, by its annotation
  *
  * @param $object
  * @param \Flowpack\ElasticSearch\Domain\Model\Client $client
  *
  * @return \Flowpack\ElasticSearch\Domain\Model\GenericType
  */
 protected function getIndexTypeForObject($object, Client $client = null)
 {
     if ($client === null) {
         $client = $this->client;
     }
     $className = $this->reflectionService->getClassNameByObject($object);
     $indexAnnotation = $this->indexInformer->getClassAnnotation($className);
     if ($indexAnnotation === null) {
         return null;
     }
     $index = $client->findIndex($indexAnnotation->indexName);
     $type = new GenericType($index, $indexAnnotation->typeName);
     return $type;
 }
开发者ID:robertlemke,项目名称:Flowpack.ElasticSearch,代码行数:22,代码来源:ObjectIndexer.php

示例4: onFlush

 /**
  * An onFlush event listener used to validate entities upon persistence.
  *
  * @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
  * @return void
  */
 public function onFlush(\Doctrine\ORM\Event\OnFlushEventArgs $eventArgs)
 {
     $unitOfWork = $this->entityManager->getUnitOfWork();
     $entityInsertions = $unitOfWork->getScheduledEntityInsertions();
     $validatedInstancesContainer = new \SplObjectStorage();
     $knownValueObjects = array();
     foreach ($entityInsertions as $entity) {
         if ($this->reflectionService->getClassSchema($entity)->getModelType() === \TYPO3\Flow\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT) {
             $identifier = $this->getIdentifierByObject($entity);
             $className = $this->reflectionService->getClassNameByObject($entity);
             if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) {
                 unset($entityInsertions[spl_object_hash($entity)]);
                 continue;
             }
             $knownValueObjects[$className][$identifier] = TRUE;
         }
         $this->validateObject($entity, $validatedInstancesContainer);
     }
     \TYPO3\Flow\Reflection\ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, TRUE);
     foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) {
         $this->validateObject($entity, $validatedInstancesContainer);
     }
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:29,代码来源:PersistenceManager.php

示例5: transformObject

 /**
  * Traverses the given object structure in order to transform it into an
  * array structure.
  *
  * @param object $object Object to traverse
  * @param array $configuration Configuration for transforming the given object or NULL
  * @return array Object structure as an array
  */
 protected function transformObject($object, array $configuration)
 {
     if ($object instanceof \DateTime) {
         return $object->format(\DateTime::ISO8601);
     } else {
         $propertyNames = \TYPO3\Flow\Reflection\ObjectAccess::getGettablePropertyNames($object);
         $propertiesToRender = array();
         foreach ($propertyNames as $propertyName) {
             if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
                 continue;
             }
             if (isset($configuration['_exclude']) && is_array($configuration['_exclude']) && in_array($propertyName, $configuration['_exclude'])) {
                 continue;
             }
             $propertyValue = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName);
             if (!is_array($propertyValue) && !is_object($propertyValue)) {
                 $propertiesToRender[$propertyName] = $propertyValue;
             } elseif (isset($configuration['_descend']) && array_key_exists($propertyName, $configuration['_descend'])) {
                 $propertiesToRender[$propertyName] = $this->transformValue($propertyValue, $configuration['_descend'][$propertyName]);
             }
         }
         if (isset($configuration['_exposeObjectIdentifier']) && $configuration['_exposeObjectIdentifier'] === TRUE) {
             if (isset($configuration['_exposedObjectIdentifierKey']) && strlen($configuration['_exposedObjectIdentifierKey']) > 0) {
                 $identityKey = $configuration['_exposedObjectIdentifierKey'];
             } else {
                 $identityKey = '__identity';
             }
             $propertiesToRender[$identityKey] = $this->persistenceManager->getIdentifierByObject($object);
         }
         if (isset($configuration['_exposeClassName']) && ($configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED || $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_UNQUALIFIED)) {
             $className = $this->reflectionService->getClassNameByObject($object);
             $classNameParts = explode('\\', $className);
             $propertiesToRender['__class'] = $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED ? $className : array_pop($classNameParts);
         }
         return $propertiesToRender;
     }
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:45,代码来源:JsonView.php

示例6: checkSingleConstraintDefinitionOnResultObject

 /**
  * Checks, if the given constraint holds for the passed result.
  *
  * @param array $constraintDefinition The constraint definition array
  * @param object $result The result object returned by the persistence manager
  * @return boolean TRUE if the query result is valid for the given constraint
  * @throws \TYPO3\Flow\Security\Exception\InvalidQueryRewritingConstraintException
  */
 protected function checkSingleConstraintDefinitionOnResultObject(array $constraintDefinition, $result)
 {
     $referenceToThisFound = FALSE;
     if (!is_array($constraintDefinition['leftValue']) && strpos($constraintDefinition['leftValue'], 'this.') === 0) {
         $referenceToThisFound = TRUE;
         $propertyPath = substr($constraintDefinition['leftValue'], 5);
         $leftOperand = $this->getObjectValueByPath($result, $propertyPath);
     } else {
         $leftOperand = $this->getValueForOperand($constraintDefinition['leftValue']);
     }
     if (!is_array($constraintDefinition['rightValue']) && strpos($constraintDefinition['rightValue'], 'this.') === 0) {
         $referenceToThisFound = TRUE;
         $propertyPath = substr($constraintDefinition['rightValue'], 5);
         $rightOperand = $this->getObjectValueByPath($result, $propertyPath);
     } else {
         $rightOperand = $this->getValueForOperand($constraintDefinition['rightValue']);
     }
     if ($referenceToThisFound === FALSE) {
         throw new InvalidQueryRewritingConstraintException('An entity security constraint must have at least one operand that references to "this.". Got: "' . $constraintDefinition['leftValue'] . '" and "' . $constraintDefinition['rightValue'] . '"', 1277218400);
     }
     if (is_object($leftOperand) && ($this->reflectionService->isClassAnnotatedWith($this->reflectionService->getClassNameByObject($leftOperand), 'TYPO3\\Flow\\Annotations\\Entity') || $this->reflectionService->isClassAnnotatedWith($this->reflectionService->getClassNameByObject($leftOperand), 'Doctrine\\ORM\\Mapping\\Entity'))) {
         $originalLeftOperand = $leftOperand;
         $leftOperand = $this->persistenceManager->getIdentifierByObject($leftOperand);
     }
     if (is_object($rightOperand) && ($this->reflectionService->isClassAnnotatedWith($this->reflectionService->getClassNameByObject($rightOperand), 'TYPO3\\Flow\\Annotations\\Entity') || $this->reflectionService->isClassAnnotatedWith($this->reflectionService->getClassNameByObject($rightOperand), 'Doctrine\\ORM\\Mapping\\Entity'))) {
         $originalRightOperand = $rightOperand;
         $rightOperand = $this->persistenceManager->getIdentifierByObject($rightOperand);
     }
     switch ($constraintDefinition['operator']) {
         case '!=':
             return $leftOperand !== $rightOperand;
             break;
         case '==':
             return $leftOperand === $rightOperand;
             break;
         case '<':
             return $leftOperand < $rightOperand;
             break;
         case '>':
             return $leftOperand > $rightOperand;
             break;
         case '<=':
             return $leftOperand <= $rightOperand;
             break;
         case '>=':
             return $leftOperand >= $rightOperand;
             break;
         case 'in':
             if ($rightOperand instanceof Collection) {
                 return $rightOperand->contains(isset($originalLeftOperand) ? $originalLeftOperand : $leftOperand);
             }
             return in_array(isset($originalLeftOperand) ? $originalLeftOperand : $leftOperand, $rightOperand);
             break;
         case 'contains':
             if ($leftOperand instanceof Collection) {
                 return $leftOperand->contains(isset($originalRightOperand) ? $originalRightOperand : $rightOperand);
             }
             return in_array(isset($originalRightOperand) ? $originalRightOperand : $rightOperand, $leftOperand);
             break;
         case 'matches':
             if ($leftOperand instanceof Collection) {
                 $leftOperand = $leftOperand->toArray();
             }
             if ($rightOperand instanceof Collection) {
                 $rightOperand = $rightOperand->toArray();
             }
             return count(array_intersect($leftOperand, $rightOperand)) !== 0;
             break;
     }
     throw new InvalidQueryRewritingConstraintException('The configured operator of the entity constraint is not valid. Got: ' . $constraintDefinition['operator'], 1277222521);
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:79,代码来源:PersistenceQueryRewritingAspect.php


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