/** * 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->identityMap->hasIdentifier($row['uid'], $className)) { $object = $this->identityMap->getObjectByIdentifier($row['uid'], $className); } else { $object = $this->createEmptyObject($className); $this->identityMap->registerObject($object, $row['uid']); $this->thawProperties($object, $row); $object->_memorizeCleanState(); $this->persistenceSession->registerReconstitutedObject($object); } return $object; }
/** * Inserts an object in the storage backend * * @param Tx_Extbase_DomainObject_DomainObjectInterface $object The object to be insterted in the storage * @return void */ protected function insertObject(Tx_Extbase_DomainObject_DomainObjectInterface $object, array $row = array()) { $dataMap = $this->dataMapper->getDataMap(get_class($object)); $this->addCommonFieldsToRow($object, $row); if ($dataMap->getLanguageIdColumnName() !== NULL) { $row[$dataMap->getLanguageIdColumnName()] = -1; } $uid = $this->storageBackend->addRow($dataMap->getTableName(), $row); $object->_setProperty('uid', (int) $uid); if ($this->extbaseSettings['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($dataMap->getTableName(), $uid); } $this->identityMap->registerObject($object, $uid); }
/** * Finds an object matching the given identifier. * * @param int $uid The identifier of the object to find * @return object The matching object if found, otherwise NULL * @api */ public function findByUid($uid) { if ($this->identityMap->hasIdentifier($uid, $this->objectType)) { $object = $this->identityMap->getObjectByIdentifier($uid, $this->objectType); } else { $query = $this->createQuery(); $query->getQuerySettings()->setRespectSysLanguage(FALSE); $query->getQuerySettings()->setRespectStoragePage(FALSE); $object = $query->matching($query->equals('uid', $uid))->execute()->getFirst(); if ($object !== NULL) { $this->identityMap->registerObject($object, $uid); } } return $object; }
/** * Inserts an object in the storage backend * * @param Tx_Extbase_DomainObject_DomainObjectInterface $object The object to be insterted in the storage * @return void */ protected function insertObject(Tx_Extbase_DomainObject_DomainObjectInterface $object) { if ($object instanceof Tx_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; } $uid = $this->storageBackend->addRow($dataMap->getTableName(), $row); $object->_setProperty('uid', (int) $uid); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if ($frameworkConfiguration['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($dataMap->getTableName(), $uid); } $this->identityMap->registerObject($object, $uid); }