/** * Maps a single row on an object of the given class * * @param string $className The name of the target class * @param array $row A single array with field_name => value pairs * @return object An object of the given class */ protected function mapSingleRow($className, array $row) { if ($this->persistenceSession->hasIdentifier($row['uid'], $className)) { $object = $this->persistenceSession->getObjectByIdentifier($row['uid'], $className); } else { $object = $this->createEmptyObject($className); $this->persistenceSession->registerObject($object, $row['uid']); $this->thawProperties($object, $row); $object->_memorizeCleanState(); $this->persistenceSession->registerReconstitutedEntity($object); } return $object; }
/** * This is a workaround to help controller actions to find (hidden) posts. * * @param $argumentName */ protected function registerClubFromRequest($argumentName) { $argument = $this->request->getArgument($argumentName); if (is_array($argument)) { // get club from form ($_POST) $club = $this->clubRepository->findHiddenEntryByUid($argument['__identity']); } elseif (is_object($argument)) { // get club from domain model $club = $argument; } else { // get club from UID $club = $this->clubRepository->findHiddenEntryByUid($argument); } $this->session->registerObject($club, $club->getUid()); }
/** * Inserts an object in the storage backend * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object The object to be insterted in the storage * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject The parentobject. * @param string $parentPropertyName * @return void */ protected function insertObject(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject = NULL, $parentPropertyName = '') { if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject) { $result = $this->getUidOfAlreadyPersistedValueObject($object); if ($result !== FALSE) { $object->_setProperty('uid', (int) $result); return; } } $dataMap = $this->dataMapper->getDataMap(get_class($object)); $row = array(); $this->addCommonFieldsToRow($object, $row); if ($dataMap->getLanguageIdColumnName() !== NULL) { $row[$dataMap->getLanguageIdColumnName()] = -1; } if ($parentObject !== NULL && $parentPropertyName) { $parentColumnDataMap = $this->dataMapper->getDataMap(get_class($parentObject))->getColumnMap($parentPropertyName); $relationTableMatchFields = $parentColumnDataMap->getRelationTableMatchFields(); if (is_array($relationTableMatchFields)) { $row = array_merge($relationTableMatchFields, $row); } if ($parentColumnDataMap->getParentKeyFieldName() !== NULL) { $row[$parentColumnDataMap->getParentKeyFieldName()] = (int) $parentObject->getUid(); } } $uid = $this->storageBackend->addRow($dataMap->getTableName(), $row); $object->_setProperty('uid', (int) $uid); $object->setPid((int) $row['pid']); if ((int) $uid >= 1) { $this->emitAfterInsertObjectSignal($object); } $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if ($frameworkConfiguration['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($dataMap->getTableName(), $uid); } $this->session->registerObject($object, $uid); if ((int) $uid >= 1) { $this->emitEndInsertObjectSignal($object); } }
/** * Inserts an object in the storage backend * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object The object to be insterted in the storage * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject The parentobject. * @param string $parentPropertyName * @return void */ protected function insertObject(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject = null, $parentPropertyName = '') { if ($object instanceof \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject) { $result = $this->getUidOfAlreadyPersistedValueObject($object); if ($result !== false) { $object->_setProperty('uid', (int) $result); return; } } $dataMap = $this->dataMapper->getDataMap(get_class($object)); $row = array(); $properties = $object->_getProperties(); foreach ($properties as $propertyName => $propertyValue) { if (!$dataMap->isPersistableProperty($propertyName) || $this->propertyValueIsLazyLoaded($propertyValue)) { continue; } $columnMap = $dataMap->getColumnMap($propertyName); if ($columnMap->getTypeOfRelation() === ColumnMap::RELATION_HAS_ONE) { $row[$columnMap->getColumnName()] = 0; } elseif ($columnMap->getTypeOfRelation() !== ColumnMap::RELATION_NONE) { if ($columnMap->getParentKeyFieldName() === null) { // CSV type relation $row[$columnMap->getColumnName()] = ''; } else { // MM type relation $row[$columnMap->getColumnName()] = 0; } } elseif ($propertyValue !== null) { $row[$columnMap->getColumnName()] = $this->dataMapper->getPlainValue($propertyValue); } } $this->addCommonFieldsToRow($object, $row); if ($dataMap->getLanguageIdColumnName() !== null && $object->_getProperty('_languageUid') === null) { $row[$dataMap->getLanguageIdColumnName()] = 0; $object->_setProperty('_languageUid', 0); } if ($dataMap->getTranslationOriginColumnName() !== null) { $row[$dataMap->getTranslationOriginColumnName()] = 0; } if ($dataMap->getTranslationOriginDiffSourceName() !== null) { $row[$dataMap->getTranslationOriginDiffSourceName()] = ''; } if ($parentObject !== null && $parentPropertyName) { $parentColumnDataMap = $this->dataMapper->getDataMap(get_class($parentObject))->getColumnMap($parentPropertyName); $relationTableMatchFields = $parentColumnDataMap->getRelationTableMatchFields(); if (is_array($relationTableMatchFields)) { $row = array_merge($relationTableMatchFields, $row); } if ($parentColumnDataMap->getParentKeyFieldName() !== null) { $row[$parentColumnDataMap->getParentKeyFieldName()] = (int) $parentObject->getUid(); } } $uid = $this->storageBackend->addRow($dataMap->getTableName(), $row); $object->_setProperty('uid', (int) $uid); $object->setPid((int) $row['pid']); if ((int) $uid >= 1) { $this->emitAfterInsertObjectSignal($object); } $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if ($frameworkConfiguration['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($dataMap->getTableName(), $uid); } $this->session->registerObject($object, $uid); if ((int) $uid >= 1) { $this->emitEndInsertObjectSignal($object); } }
/** * Register a node identifier for an object * * @param object $object * @param string $uuid * @deprecated since 6.1, will be removed two versions later, use the persistence session instead */ public function registerObject($object, $uuid) { $this->persistenceSession->registerObject($object, $uuid); }