94 public function map($className, array $rows) {
96 foreach ($rows as $row) {
111 $targetType = $className;
112 if ($dataMap->getRecordTypeColumnName() !== NULL) {
113 foreach ($dataMap->getSubclasses() as $subclassName) {
114 $recordSubtype = $this->
getDataMap($subclassName)->getRecordType();
115 if ($row[$dataMap->getRecordTypeColumnName()] === $recordSubtype) {
116 $targetType = $subclassName;
132 if ($this->identityMap->hasIdentifier($row[
'uid'], $className)) {
133 $object = $this->identityMap->getObjectByIdentifier($row[
'uid'], $className);
136 $this->identityMap->registerObject($object, $row[
'uid']);
138 $object->_memorizeCleanState();
139 $this->persistenceSession->registerReconstitutedEntity($object);
154 if (!in_array(
'TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface', class_implements($className))) {
155 throw new \TYPO3\CMS\Extbase\Object\Exception\CannotReconstituteObjectException(
'Cannot create empty instance of the class "' . $className .
'" because it does not implement the TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface.', 1234386924);
157 $object = $this->objectManager->getEmptyObject($className);
169 $className = get_class($object);
170 $classSchema = $this->reflectionService->getClassSchema($className);
172 $object->_setProperty(
'uid', (
int)$row[
'uid']);
173 $object->_setProperty(
'pid', (
int)$row[
'pid']);
174 $object->_setProperty(
'_localizedUid', (
int)$row[
'uid']);
175 $object->_setProperty(
'_versionedUid', (
int)$row[
'uid']);
176 if ($dataMap->getLanguageIdColumnName() !== NULL) {
177 $object->_setProperty(
'_languageUid', (
int)$row[$dataMap->getLanguageIdColumnName()]);
178 if (isset($row[
'_LOCALIZED_UID'])) {
179 $object->_setProperty(
'_localizedUid', (
int)$row[
'_LOCALIZED_UID']);
182 if (!empty($row[
'_ORIG_uid']) && !empty(
$GLOBALS[
'TCA'][$dataMap->getTableName()][
'ctrl'][
'versioningWS'])) {
183 $object->_setProperty(
'_versionedUid', (
int)$row[
'_ORIG_uid']);
185 $properties = $object->_getProperties();
186 foreach ($properties as $propertyName => $propertyValue) {
187 if (!$dataMap->isPersistableProperty($propertyName)) {
190 $columnMap = $dataMap->getColumnMap($propertyName);
191 $columnName = $columnMap->getColumnName();
192 $propertyData = $classSchema->getProperty($propertyName);
193 $propertyValue = NULL;
194 if ($row[$columnName] !== NULL) {
195 switch ($propertyData[
'type']) {
197 $propertyValue = (int)$row[$columnName];
200 $propertyValue = (double)$row[$columnName];
203 $propertyValue = (bool)$row[$columnName];
206 $propertyValue = (string)$row[$columnName];
211 case 'SplObjectStorage':
212 case 'Tx_Extbase_Persistence_ObjectStorage':
213 case 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage':
217 $this->
fetchRelated($object, $propertyName, $row[$columnName])
221 if ($propertyData[
'type'] ===
'DateTime' || in_array(
'DateTime', class_parents($propertyData[
'type']))) {
222 $propertyValue = $this->
mapDateTime($row[$columnName], $columnMap->getDateTimeStorageFormat(), $propertyData[
'type']);
224 $propertyValue = $this->
mapCoreType($propertyData[
'type'], $row[$columnName]);
235 if ($propertyValue !== NULL) {
236 $object->_setProperty($propertyName, $propertyValue);
249 return new $type($value);
261 protected function mapDateTime($value, $storageFormat = NULL, $targetType =
'DateTime') {
262 if (empty($value) || $value ===
'0000-00-00' || $value ===
'0000-00-00 00:00:00') {
265 } elseif ($storageFormat ===
'date' || $storageFormat ===
'datetime') {
267 $utcTimeZone = new \DateTimeZone(
'UTC');
269 $currentTimeZone = new \DateTimeZone(date_default_timezone_get());
270 return $utcDateTime->setTimezone($currentTimeZone);
272 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($targetType, date(
'c', $value));
286 $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
287 if ($enableLazyLoading === TRUE && $propertyMetaData[
'lazy']) {
288 if (in_array($propertyMetaData[
'type'], array(
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
'Tx_Extbase_Persistence_ObjectStorage'), TRUE)) {
289 $result = $this->objectManager->get(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage', $parentObject, $propertyName, $fieldValue);
291 if (empty($fieldValue)) {
294 $result = $this->objectManager->get(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyLoadingProxy', $parentObject, $propertyName, $fieldValue);
321 $columnMap = $this->
getDataMap(get_class($parentObject))->getColumnMap($propertyName);
323 return $relatesToOne ? NULL : array();
333 $query = $this->
getPreparedQuery($parentObject, $propertyName, $fieldValue);
334 return $query->execute();
346 $columnMap = $this->
getDataMap(get_class($parentObject))->getColumnMap($propertyName);
347 $type = $this->
getType(get_class($parentObject), $propertyName);
348 $query = $this->queryFactory->create($type);
349 $query->getQuerySettings()->setRespectStoragePage(FALSE);
350 $query->getQuerySettings()->setRespectSysLanguage(FALSE);
352 if ($columnMap->getChildSortByFieldName() !== NULL) {
356 $query->setSource($this->
getSource($parentObject, $propertyName));
357 if ($columnMap->getChildSortByFieldName() !== NULL) {
361 $query->matching($this->
getConstraint($query, $parentObject, $propertyName, $fieldValue, $columnMap->getRelationTableMatchFields()));
376 $columnMap = $this->
getDataMap(get_class($parentObject))->getColumnMap($propertyName);
377 if ($columnMap->getParentKeyFieldName() !== NULL) {
378 $constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject);
379 if ($columnMap->getParentTableFieldName() !== NULL) {
380 $constraint = $query->logicalAnd($constraint, $query->equals($columnMap->getParentTableFieldName(), $this->
getDataMap(get_class($parentObject))->getTableName()));
385 if (count($relationTableMatchFields) > 0) {
386 foreach ($relationTableMatchFields as $relationTableMatchFieldName => $relationTableMatchFieldValue) {
387 $constraint = $query->logicalAnd($constraint, $query->equals($relationTableMatchFieldName, $relationTableMatchFieldValue));
401 $columnMap = $this->
getDataMap(get_class($parentObject))->getColumnMap($propertyName);
402 $left = $this->qomFactory->selector(NULL, $columnMap->getRelationTableName());
403 $childClassName = $this->
getType(get_class($parentObject), $propertyName);
404 $right = $this->qomFactory->selector($childClassName, $columnMap->getChildTableName());
405 $joinCondition = $this->qomFactory->equiJoinCondition($columnMap->getRelationTableName(), $columnMap->getChildKeyFieldName(), $columnMap->getChildTableName(),
'uid');
430 if ($fieldValue ===
'') {
433 $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
434 if ($this->persistenceSession->hasIdentifier($fieldValue, $propertyMetaData[
'type'])) {
435 $propertyValue = $this->persistenceSession->getObjectByIdentifier($fieldValue, $propertyMetaData[
'type']);
443 return $propertyValue;
454 $columnMap = $this->
getDataMap(get_class($parentObject))->getColumnMap($propertyName);
455 return ($columnMap->getParentKeyFieldName() !== NULL);
467 $propertyValue = NULL;
471 $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
472 if (in_array($propertyMetaData[
'type'], array(
'array',
'ArrayObject',
'SplObjectStorage',
'Tx_Extbase_Persistence_ObjectStorage',
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage'), TRUE)) {
477 if ($propertyMetaData[
'type'] ===
'ArrayObject') {
478 $propertyValue = new \ArrayObject($objects);
479 } elseif (in_array($propertyMetaData[
'type'], array(
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
'Tx_Extbase_Persistence_ObjectStorage'), TRUE)) {
480 $propertyValue = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
481 foreach ($objects as $object) {
482 $propertyValue->attach($object);
484 $propertyValue->_memorizeCleanState();
486 $propertyValue = $objects;
488 } elseif (strpbrk($propertyMetaData[
'type'],
'_\\') !== FALSE) {
490 $propertyValue =
$result->getFirst();
496 return $propertyValue;
508 $query = $this->
getPreparedQuery($parentObject, $propertyName, $fieldValue);
509 return $query->execute()->count();
522 return $dataMap->isPersistableProperty($propertyName);
533 if (!is_string($className) || strlen($className) === 0) {
534 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception(
'No class name was given to retrieve the Data Map for.', 1251315965);
536 if (!isset($this->dataMaps[$className])) {
537 $this->dataMaps[$className] = $this->dataMapFactory->buildDataMap($className);
539 return $this->dataMaps[$className];
549 if ($className !== NULL) {
550 $tableName = $this->
getDataMap($className)->getTableName();
552 $tableName = strtolower($className);
565 if (!empty($className)) {
567 if ($dataMap !== NULL) {
568 $columnMap = $dataMap->getColumnMap($propertyName);
569 if ($columnMap !== NULL) {
570 return $columnMap->getColumnName();
574 return \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
585 public function getType($parentClassName, $propertyName) {
586 $propertyMetaData = $this->reflectionService->getClassSchema($parentClassName)->getProperty($propertyName);
587 if (!empty($propertyMetaData[
'elementType'])) {
588 $type = $propertyMetaData[
'elementType'];
589 } elseif (!empty($propertyMetaData[
'type'])) {
590 $type = $propertyMetaData[
'type'];
592 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnexpectedTypeException(
'Could not determine the child object type.', 1251315967);
const RELATION_HAS_AND_BELONGS_TO_MANY
isPersistableProperty($className, $propertyName)
getSource(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName)
getNonEmptyRelationValue(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue)
mapCoreType($type, $value)
getTargetType($className, array $row)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
const JCR_JOIN_TYPE_INNER
createEmptyObject($className)
thawProperties(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object, array $row)
getEmptyRelationValue(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName)
fetchRelatedEager(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
mapResultToPropertyValue(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $result)
mapObjectToClassProperty(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue)
static makeInstance($className)
countRelated(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
propertyMapsByForeignKey(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName)
convertPropertyNameToColumnName($propertyName, $className=NULL)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
convertClassNameToTableName($className=NULL)
mapSingleRow($className, array $row)
mapDateTime($value, $storageFormat=NULL, $targetType='DateTime')
fetchRelated(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue='', $enableLazyLoading=TRUE)
getConstraint(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query, \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue='', $relationTableMatchFields=array())
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getType($parentClassName, $propertyName)
getPreparedQuery(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
map($className, array $rows)