/** * @param \Iterator|\TYPO3\CMS\Extbase\DomainObject\AbstractEntity[] $iterator * @return array */ protected function getStructure($iterator) { $structure = array(); if (!$iterator instanceof \Iterator) { $iterator = array($iterator); } foreach ($iterator as $entity) { $dataMap = $this->dataMapFactory->buildDataMap(get_class($entity)); $tableName = $dataMap->getTableName(); $identifier = $tableName . ':' . $entity->getUid(); $properties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettableProperties($entity); $structureItem = array(); foreach ($properties as $propertyName => $propertyValue) { $columnMap = $dataMap->getColumnMap($propertyName); if ($columnMap !== NULL) { $propertyName = $columnMap->getColumnName(); } if ($propertyValue instanceof \Iterator) { $structureItem[$propertyName] = $this->getStructure($propertyValue); } else { $structureItem[$propertyName] = $propertyValue; } } $structure[$identifier] = $structureItem; } return $structure; }
/** * Returns a data map for a given class name * * @param string $className The class name you want to fetch the Data Map for * @throws Persistence\Generic\Exception * @return DataMap The data map */ public function getDataMap($className) { if (!is_string($className) || $className === '') { throw new Persistence\Generic\Exception('No class name was given to retrieve the Data Map for.', 1251315965); } if (!isset($this->dataMaps[$className])) { $this->dataMaps[$className] = $this->dataMapFactory->buildDataMap($className); } return $this->dataMaps[$className]; }