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


PHP ObjectAccess::getGettablePropertyNames方法代码示例

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


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

示例1: getPropertyNames

 /**
  * Returns the names of all properties of this node.
  *
  * @return array Property names
  */
 public function getPropertyNames()
 {
     if (is_object($this->contentObjectProxy)) {
         return ObjectAccess::getGettablePropertyNames($this->contentObjectProxy->getObject());
     }
     return array_keys($this->properties);
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3CR,代码行数:12,代码来源:AbstractNodeData.php

示例2: getJsonRepresentation

 /**
  * @param $entityName
  * @return string
  */
 protected function getJsonRepresentation($entityName)
 {
     $entityData = $this->getObjectsFromRepository($entityName);
     $entityArray = [];
     foreach ($entityData as $object) {
         $propertyNames = \TYPO3\Flow\Reflection\ObjectAccess::getGettablePropertyNames($object);
         $identifier = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, 'uUID');
         foreach ($propertyNames as $propertyName) {
             $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]);
             }
             $entityArray[] = $propertiesToRender;
         }
     }
     return json_encode(['data' => [$entityArray]]);
 }
开发者ID:subugoe,项目名称:germaniasacra,代码行数:23,代码来源:JsonGeneratorService.php

示例3: getGettablePropertyNamesReturnsAllPropertiesWhichAreAvailable

 /**
  * @test
  */
 public function getGettablePropertyNamesReturnsAllPropertiesWhichAreAvailable()
 {
     $expectedPropertyNames = array('anotherProperty', 'booleanProperty', 'property', 'property2', 'publicProperty', 'publicProperty2');
     $actualPropertyNames = ObjectAccess::getGettablePropertyNames($this->dummyObject);
     $this->assertEquals($expectedPropertyNames, $actualPropertyNames, 'getGettablePropertyNames returns not all gettable properties.');
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:9,代码来源:ObjectAccessTest.php

示例4: 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 = TypeHandling::getTypeForValue($object);
             $classNameParts = explode('\\', $className);
             $propertiesToRender['__class'] = $configuration['_exposeClassName'] === self::EXPOSE_CLASSNAME_FULLY_QUALIFIED ? $className : array_pop($classNameParts);
         }
         return $propertiesToRender;
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:45,代码来源:JsonView.php

示例5: mapToStructure

 /**
  * map data to simple data structures
  *
  * @param mixed $data
  * @return mixed
  */
 protected function mapToStructure($data)
 {
     return $data;
     if (is_array($data) || is_object($data) && $data instanceof \Traversable) {
         $return = array();
         foreach ($data as $index => $item) {
             $return[$index] = $this->mapToStructure($item);
         }
     } else {
         if (is_object($data)) {
             $return = new \stdClass();
             $properties = \TYPO3\Flow\Reflection\ObjectAccess::getGettablePropertyNames($data);
             foreach ($properties as $property) {
                 $return->{$property} = $this->mapToStructure(\TYPO3\Flow\Reflection\ObjectAccess::getProperty($data, $property));
             }
         } else {
             $return = $data;
         }
     }
     return $return;
 }
开发者ID:benovie,项目名称:PerfectIn.Api,代码行数:27,代码来源:WebserviceCall.php

示例6: 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
  * @return array Object structure as an array
  * @todo implement sideloading
  */
 protected function transformObject($object, array $configuration, $onlyIdentifier = TRUE)
 {
     if ($object instanceof \DateTime) {
         return $object->format('Y-m-d\\TH:i:s');
     } elseif ($onlyIdentifier === TRUE) {
         $objectIdentifier = $this->persistenceManager->getIdentifierByObject($object);
         if ($objectIdentifier === NULL && method_exists($object, 'getId')) {
             $objectIdentifier = $object->getId();
         }
         return $objectIdentifier;
     } else {
         $transformedObject = array();
         if ($this->excludeIdentifier === FALSE) {
             $objectIdentifier = $this->persistenceManager->getIdentifierByObject($object);
             $transformedObject['id'] = $objectIdentifier;
         }
         $propertyNames = ObjectAccess::getGettablePropertyNames($object);
         foreach ($propertyNames as $propertyName) {
             if (substr($propertyName, 0, 1) !== '_') {
                 if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
                     continue;
                 }
                 if ($this->propertyIsExcluded($propertyName, $configuration)) {
                     continue;
                 }
                 $propertyValue = ObjectAccess::getProperty($object, $propertyName);
                 $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
                 if (!$this->reflectionService->isPropertyAnnotatedWith($objectName, $propertyName, 'TYPO3\\Flow\\Annotations\\Transient')) {
                     if (is_array($propertyValue) || $propertyValue instanceof \ArrayAccess) {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $this->transformValue($propertyValue, array());
                     } elseif ($propertyValue instanceof \DateTime) {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $propertyValue->format('Y-m-d\\TH:i:s');
                     } elseif (is_object($propertyValue)) {
                         $objectName = $this->objectManager->getObjectNameByClassName($this->reflectionService->getClassNameByObject($object));
                         if ($this->objectManager->getScope($objectName) !== \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) {
                             $transformedObject[EmberDataUtility::uncamelize($propertyName) . '_id'] = $this->persistenceManager->getIdentifierByObject($propertyValue);
                             if (isset($configuration['sideloadedAssociations']) && in_array($propertyName, $configuration['sideloadedAssociations'])) {
                                 // sideload this propertyvalue
                             }
                         }
                     } else {
                         $transformedObject[EmberDataUtility::uncamelize($propertyName)] = $propertyValue;
                     }
                 }
             }
         }
         return $transformedObject;
     }
 }
开发者ID:putheakhem,项目名称:Radmiraal.Emberjs,代码行数:59,代码来源:RestView.php

示例7: 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


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