本文整理汇总了PHP中TYPO3\Flow\Reflection\ReflectionService::isPropertyTaggedWith方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionService::isPropertyTaggedWith方法的具体用法?PHP ReflectionService::isPropertyTaggedWith怎么用?PHP ReflectionService::isPropertyTaggedWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ReflectionService
的用法示例。
在下文中一共展示了ReflectionService::isPropertyTaggedWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serializeObjectAsPropertyArray
/**
* Serializes an object as property array.
*
* @param object $object The object to store in the registry
* @param boolean $isTopLevelItem Internal flag for managing the recursion
* @return array The property array
*/
public function serializeObjectAsPropertyArray($object, $isTopLevelItem = true)
{
if ($isTopLevelItem) {
$this->objectReferences = new \SplObjectStorage();
}
$this->objectReferences->attach($object);
$className = get_class($object);
$propertyArray = array();
foreach ($this->reflectionService->getClassPropertyNames($className) as $propertyName) {
if ($this->reflectionService->isPropertyTaggedWith($className, $propertyName, 'transient')) {
continue;
}
$propertyReflection = new \TYPO3\Flow\Reflection\PropertyReflection($className, $propertyName);
$propertyValue = $propertyReflection->getValue($object);
if (is_object($propertyValue) && $propertyValue instanceof \TYPO3\Flow\Object\DependencyInjection\DependencyProxy) {
continue;
}
if (is_object($propertyValue) && isset($this->objectReferences[$propertyValue])) {
$propertyArray[$propertyName][self::TYPE] = 'object';
$propertyArray[$propertyName][self::VALUE] = \spl_object_hash($propertyValue);
continue;
}
$propertyClassName = is_object($propertyValue) ? get_class($propertyValue) : '';
if ($propertyClassName === 'SplObjectStorage') {
$propertyArray[$propertyName][self::TYPE] = 'SplObjectStorage';
$propertyArray[$propertyName][self::VALUE] = array();
foreach ($propertyValue as $storedObject) {
$propertyArray[$propertyName][self::VALUE][] = spl_object_hash($storedObject);
$this->serializeObjectAsPropertyArray($storedObject, false);
}
} elseif (is_object($propertyValue) && $propertyValue instanceof \Doctrine\Common\Collections\Collection) {
$propertyArray[$propertyName][self::TYPE] = 'Collection';
$propertyArray[$propertyName][self::CLASSNAME] = get_class($propertyValue);
foreach ($propertyValue as $storedObject) {
$propertyArray[$propertyName][self::VALUE][] = spl_object_hash($storedObject);
$this->serializeObjectAsPropertyArray($storedObject, false);
}
} elseif (is_object($propertyValue) && $propertyValue instanceof \ArrayObject) {
$propertyArray[$propertyName][self::TYPE] = 'ArrayObject';
$propertyArray[$propertyName][self::VALUE] = $this->buildStorageArrayForArrayProperty($propertyValue->getArrayCopy());
} elseif (is_object($propertyValue) && $this->persistenceManager->isNewObject($propertyValue) === false && ($this->reflectionService->isClassAnnotatedWith($propertyClassName, \TYPO3\Flow\Annotations\Entity::class) || $this->reflectionService->isClassAnnotatedWith($propertyClassName, \TYPO3\Flow\Annotations\ValueObject::class) || $this->reflectionService->isClassAnnotatedWith($propertyClassName, 'Doctrine\\ORM\\Mapping\\Entity'))) {
$propertyArray[$propertyName][self::TYPE] = 'persistenceObject';
$propertyArray[$propertyName][self::VALUE] = get_class($propertyValue) . ':' . $this->persistenceManager->getIdentifierByObject($propertyValue);
} elseif (is_object($propertyValue)) {
$propertyObjectName = $this->objectManager->getObjectNameByClassName($propertyClassName);
if ($this->objectManager->getScope($propertyObjectName) === \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) {
continue;
}
$propertyArray[$propertyName][self::TYPE] = 'object';
$propertyArray[$propertyName][self::VALUE] = spl_object_hash($propertyValue);
$this->serializeObjectAsPropertyArray($propertyValue, false);
} elseif (is_array($propertyValue)) {
$propertyArray[$propertyName][self::TYPE] = 'array';
$propertyArray[$propertyName][self::VALUE] = $this->buildStorageArrayForArrayProperty($propertyValue);
} else {
$propertyArray[$propertyName][self::TYPE] = 'simple';
$propertyArray[$propertyName][self::VALUE] = $propertyValue;
}
}
$this->objectsAsArray[spl_object_hash($object)] = array(self::CLASSNAME => $className, self::PROPERTIES => $propertyArray);
if ($isTopLevelItem) {
return $this->objectsAsArray;
}
}