/** * Populate this proxy by asking the $population closure. * * @return object The instance (hopefully) returned */ public function _loadRealInstance() { // this check safeguards against a proxy being activated multiple times // usually that does not happen, but if the proxy is held from outside // its parent ... the result would be weird. if ($this->parentObject->_getProperty($this->propertyName) instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) { $objects = $this->dataMapper->fetchRelated($this->parentObject, $this->propertyName, $this->fieldValue, false, false); $propertyValue = $this->dataMapper->mapResultToPropertyValue($this->parentObject, $this->propertyName, $objects); $this->parentObject->_setProperty($this->propertyName, $propertyValue); $this->parentObject->_memorizeCleanState($this->propertyName); return $propertyValue; } else { return $this->parentObject->_getProperty($this->propertyName); } }
/** * Returns the property data from the given model * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $model * @param string $propertyKey * @return mixed */ public function getModelProperty($model, $propertyKey) { $propertyValue = $model->_getProperty($propertyKey); if (is_object($propertyValue)) { if ($propertyValue instanceof LazyObjectStorage) { $propertyValue = iterator_to_array($propertyValue); // Transform objects recursive foreach ($propertyValue as $childPropertyKey => $childPropertyValue) { if (is_object($childPropertyValue)) { $propertyValue[$childPropertyKey] = $this->getModelData($childPropertyValue); } } $propertyValue = array_values($propertyValue); } else { $propertyValue = $this->getModelData($propertyValue); } } else { if (!$propertyValue) { return NULL; } } return $propertyValue; }
/** * Returns the removed objects determined by a comparison of the clean property value * with the actual property value. * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object The object * @param string $propertyName * @return array An array of removed objects */ protected function getRemovedChildObjects(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, $propertyName) { $removedObjects = array(); $cleanPropertyValue = $object->_getCleanProperty($propertyName); if (is_array($cleanPropertyValue) || $cleanPropertyValue instanceof \Iterator) { $propertyValue = $object->_getProperty($propertyName); foreach ($cleanPropertyValue as $containedObject) { if (!$propertyValue->contains($containedObject)) { $removedObjects[] = $containedObject; } } } return $removedObjects; }