/** * Process an array of object data properties and add identifiers to fetch * for recursive processing in nested objects * * @param array &$properties * @param array &$identifiersToFetch * @param array &$knownObjects * @param \TYPO3\FLOW3\Reflection\ClassSchema $classSchema * @return void * @author Christopher Hlubek <*****@*****.**> */ protected function processResultProperties(array &$properties, array &$identifiersToFetch, array &$knownObjects, \TYPO3\FLOW3\Reflection\ClassSchema $classSchema) { foreach ($properties as $propertyName => &$propertyData) { // Skip unknown properties if (!$classSchema->hasProperty($propertyName)) { continue; } $propertyMetadata = $classSchema->getProperty($propertyName); if (!$propertyData['multivalue']) { if (isset($propertyData['value']['identifier']) && !isset($propertyData['value']['classname'])) { if ($propertyMetadata['lazy'] !== TRUE) { if (!isset($knownObjects[$propertyData['value']['identifier']])) { $identifiersToFetch[$propertyData['value']['identifier']] = NULL; $propertyData['value'] =& $identifiersToFetch[$propertyData['value']['identifier']]; } } else { $propertyData['value'] = array('identifier' => $propertyData['value']['identifier'], 'classname' => $propertyData['type'], 'properties' => array()); } } elseif (is_array($propertyData['value']) && isset($propertyData['value']['properties'])) { $this->processResultProperties($propertyData['value']['properties'], $identifiersToFetch, $knownObjects, $this->classSchemata[$propertyData['value']['classname']]); } } else { for ($index = 0; $index < count($propertyData['value']); $index++) { if (isset($propertyData['value'][$index]['value']['identifier']) && !isset($propertyData['value'][$index]['value']['classname'])) { if ($propertyMetadata['lazy'] !== TRUE) { if (!isset($knownObjects[$propertyData['value'][$index]['value']['identifier']])) { $identifiersToFetch[$propertyData['value'][$index]['value']['identifier']] = NULL; $propertyData['value'][$index]['value'] =& $identifiersToFetch[$propertyData['value'][$index]['value']['identifier']]; } } else { $propertyData['value'][$index]['value'] = array('identifier' => $propertyData['value'][$index]['value']['identifier'], 'classname' => $propertyData['value'][$index]['type'], 'properties' => array()); } } elseif (is_array($propertyData['value']) && isset($propertyData['value'][$index]['value']['properties']) && is_array($propertyData['value'][$index]['value'])) { $this->processResultProperties($propertyData['value'][$index]['value']['properties'], $identifiersToFetch, $knownObjects, $this->classSchemata[$propertyData['value'][$index]['value']['classname']]); } } } } }