/** * Returns the given result as property value of the specified property type. * * @param mixed $result The result could be an object or an ObjectStorage * @param array $propertyMetaData The property meta data * @param Tx_Extbase_Persistence_QueryResultInterface|Tx_Extbase_Persistence_LoadingStrategyInterface $result The result * @return void */ public function mapResultToPropertyValue(Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $result) { if ($result instanceof Tx_Extbase_Persistence_LoadingStrategyInterface) { $propertyValue = $result; } else { $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName); $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName); if (in_array($propertyMetaData['type'], array('array', 'ArrayObject', 'SplObjectStorage', 'Tx_Extbase_Persistence_ObjectStorage'))) { $elementType = $this->getType(get_class($parentObject), $propertyName); $objects = array(); foreach ($result as $value) { $objects[] = $value; } if ($propertyMetaData['type'] === 'ArrayObject') { $propertyValue = new ArrayObject($objects); } elseif ($propertyMetaData['type'] === 'Tx_Extbase_Persistence_ObjectStorage') { $propertyValue = new Tx_Extbase_Persistence_ObjectStorage(); foreach ($objects as $object) { $propertyValue->attach($object); } $propertyValue->_memorizeCleanState(); } else { $propertyValue = $objects; } } elseif (strpos($propertyMetaData['type'], '_') !== FALSE) { if (is_object($result) && $result instanceof Tx_Extbase_Persistence_QueryResultInterface) { $propertyValue = $result->getFirst(); } else { $propertyValue = $result; } } } return $propertyValue; }