TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 injectQomFactory (\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory)
 
 injectPersistenceSession (\TYPO3\CMS\Extbase\Persistence\Generic\Session $persistenceSession)
 
 injectDataMapFactory (\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory $dataMapFactory)
 
 injectQueryFactory (\TYPO3\CMS\Extbase\Persistence\Generic\QueryFactoryInterface $queryFactory)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 injectSignalSlotDispatcher (\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
 
 map ($className, array $rows)
 
 getTargetType ($className, array $row)
 
 fetchRelated (DomainObjectInterface $parentObject, $propertyName, $fieldValue='', $enableLazyLoading=true)
 
 mapResultToPropertyValue (DomainObjectInterface $parentObject, $propertyName, $result)
 
 countRelated (DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
 
 isPersistableProperty ($className, $propertyName)
 
 getDataMap ($className)
 
 convertClassNameToTableName ($className)
 
 convertPropertyNameToColumnName ($propertyName, $className=null)
 
 getType ($parentClassName, $propertyName)
 
 getPlainValue ($input, $columnMap=null, $parseStringValueCallback=null, array $parseStringValueCallbackParameters=[])
 

Protected Member Functions

 mapSingleRow ($className, array $row)
 
 emitAfterMappingSingleRow (DomainObjectInterface $object)
 
 createEmptyObject ($className)
 
 thawProperties (DomainObjectInterface $object, array $row)
 
 mapCoreType ($type, $value)
 
 mapDateTime ($value, $storageFormat=null, $targetType='DateTime')
 
 fetchRelatedEager (DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
 
 getEmptyRelationValue (DomainObjectInterface $parentObject, $propertyName)
 
 getNonEmptyRelationValue (DomainObjectInterface $parentObject, $propertyName, $fieldValue)
 
 getPreparedQuery (DomainObjectInterface $parentObject, $propertyName, $fieldValue='')
 
 getConstraint (Persistence\QueryInterface $query, DomainObjectInterface $parentObject, $propertyName, $fieldValue='', $relationTableMatchFields=[])
 
 getSource (DomainObjectInterface $parentObject, $propertyName)
 
 mapObjectToClassProperty (DomainObjectInterface $parentObject, $propertyName, $fieldValue)
 
 propertyMapsByForeignKey (DomainObjectInterface $parentObject, $propertyName)
 
 getPlainStringValue ($value, $callback=null, array $additionalParameters=[])
 

Protected Attributes

 $reflectionService
 
 $qomFactory
 
 $persistenceSession
 
 $pageSelectObject
 
 $dataMaps = []
 
 $dataMapFactory
 
 $queryFactory
 
 $objectManager
 
 $signalSlotDispatcher
 

Detailed Description

A mapper to map database tables configured in $TCA on domain objects.

Definition at line 26 of file DataMapper.php.

Member Function Documentation

◆ convertClassNameToTableName()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::convertClassNameToTableName (   $className)

Returns the selector (table) name for a given class name.

Parameters
string$className
Returns
string The selector name

Definition at line 628 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap().

◆ convertPropertyNameToColumnName()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::convertPropertyNameToColumnName (   $propertyName,
  $className = null 
)

Returns the column name for a given property name of the specified class.

Parameters
string$propertyName
string$className
Returns
string The column name

Definition at line 640 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap().

◆ countRelated()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::countRelated ( DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue = '' 
)

Counts the number of related objects assigned to a property of a parent object

Parameters
DomainObjectInterface$parentObjectThe object instance this proxy is part of
string$propertyNameThe name of the proxied property in it's parent
mixed$fieldValueThe raw field value.
Returns
int

Definition at line 584 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPreparedQuery().

◆ createEmptyObject()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::createEmptyObject (   $className)
protected

Creates a skeleton of the specified object

Parameters
string$classNameName of the class to create a skeleton for
Exceptions
CannotReconstituteObjectException
Returns
object The object skeleton

Definition at line 211 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapSingleRow().

◆ emitAfterMappingSingleRow()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::emitAfterMappingSingleRow ( DomainObjectInterface  $object)
protected

Emits a signal after mapping a single row.

Parameters
DomainObjectInterface$objectThe mapped object

Definition at line 199 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapSingleRow().

◆ fetchRelated()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::fetchRelated ( DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue = '',
  $enableLazyLoading = true 
)

Fetches a collection of objects related to a property of a parent object

Parameters
DomainObjectInterface$parentObjectThe object instance this proxy is part of
string$propertyNameThe name of the proxied property in it's parent
mixed$fieldValueThe raw field value.
bool$enableLazyLoadingA flag indication if the related objects should be lazy loaded
Returns
|Persistence The result

Definition at line 349 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\fetchRelatedEager().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapObjectToClassProperty(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

◆ fetchRelatedEager()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::fetchRelatedEager ( DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue = '' 
)
protected

Fetches the related objects from the storage backend.

Parameters
DomainObjectInterface$parentObjectThe object instance this proxy is part of
string$propertyNameThe name of the proxied property in it's parent
mixed$fieldValueThe raw field value.
Returns
mixed

Definition at line 376 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getEmptyRelationValue(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getNonEmptyRelationValue().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\fetchRelated().

◆ getConstraint()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getConstraint ( Persistence\QueryInterface  $query,
DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue = '',
  $relationTableMatchFields = [] 
)
protected

Builds and returns the constraint for multi value properties.

Parameters
Persistence\QueryInterface$query
DomainObjectInterface$parentObject
string$propertyName
string$fieldValue
array$relationTableMatchFields
Returns
$constraint

Definition at line 444 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap(), and TYPO3\CMS\Core\Utility\GeneralUtility\intExplode().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPreparedQuery().

◆ getDataMap()

◆ getEmptyRelationValue()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getEmptyRelationValue ( DomainObjectInterface  $parentObject,
  $propertyName 
)
protected

◆ getNonEmptyRelationValue()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getNonEmptyRelationValue ( DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue 
)
protected
Parameters
DomainObjectInterface$parentObject
string$propertyName
string$fieldValue
Returns
Persistence

Definition at line 399 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPreparedQuery().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\fetchRelatedEager().

◆ getPlainStringValue()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getPlainStringValue (   $value,
  $callback = null,
array  $additionalParameters = [] 
)
protected

If the given callback is set the value will be passed on the the callback function. The value will be converted to a string.

Parameters
string$valueThe string value that should be processed. Will be passed to the callback as first parameter.
callable$callbackThe data passed to call_user_func().
array$additionalParametersOptional additional parameters passed to the callback as second argument.
Returns
string

Definition at line 746 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPlainValue().

◆ getPlainValue()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getPlainValue (   $input,
  $columnMap = null,
  $parseStringValueCallback = null,
array  $parseStringValueCallbackParameters = [] 
)

Returns a plain value, i.e. objects are flattened out if possible. Multi value objects or arrays will be converted to a comma-separated list for use in IN SQL queries.

Parameters
mixed$inputThe value that will be converted.
ColumnMap$columnMapOptional column map for retrieving the date storage format.
callable$parseStringValueCallbackOptional callback method that will be called for string values. Can be used to do database quotation.
array$parseStringValueCallbackParametersAdditional parameters that will be passed to the callabck as second parameter.
Exceptions

Definition at line 687 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPlainStringValue(), TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCoreType(), and TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isValidTypeForMultiValueComparison().

◆ getPreparedQuery()

◆ getSource()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getSource ( DomainObjectInterface  $parentObject,
  $propertyName 
)
protected

Builds and returns the source to build a join for a m:n relation.

Parameters
DomainObjectInterface$parentObject
string$propertyName
Returns
$source

Definition at line 473 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getType(), and TYPO3\CMS\Extbase\Persistence\Generic\Query\JCR_JOIN_TYPE_INNER.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPreparedQuery().

◆ getTargetType()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getTargetType (   $className,
array  $row 
)

Returns the target type for the given row.

Parameters
string$classNameThe name of the class
array$rowA single array with field_name => value pairs
Returns
string The target type (a class name)

Definition at line 156 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\map().

◆ getType()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getType (   $parentClassName,
  $propertyName 
)

Returns the type of a child object.

Parameters
string$parentClassNameThe class name of the object this proxy is part of
string$propertyNameThe name of the proxied property in it's parent
Exceptions
UnexpectedTypeException
Returns
string The class name of the child object

Definition at line 662 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getPreparedQuery(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getSource().

◆ injectDataMapFactory()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectDataMapFactory ( \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory  $dataMapFactory)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory$dataMapFactory

Definition at line 104 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$dataMapFactory.

◆ injectObjectManager()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectObjectManager ( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

Definition at line 120 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$objectManager.

◆ injectPersistenceSession()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectPersistenceSession ( \TYPO3\CMS\Extbase\Persistence\Generic\Session  $persistenceSession)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Session$persistenceSession

Definition at line 96 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$persistenceSession.

◆ injectQomFactory()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectQomFactory ( \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory  $qomFactory)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory$qomFactory

Definition at line 88 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$qomFactory.

◆ injectQueryFactory()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectQueryFactory ( \TYPO3\CMS\Extbase\Persistence\Generic\QueryFactoryInterface  $queryFactory)
Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\QueryFactoryInterface$queryFactory

Definition at line 112 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$queryFactory.

◆ injectReflectionService()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectReflectionService ( \TYPO3\CMS\Extbase\Reflection\ReflectionService  $reflectionService)
Parameters
\TYPO3\CMS\Extbase\Reflection\ReflectionService$reflectionService

Definition at line 80 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$reflectionService.

◆ injectSignalSlotDispatcher()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::injectSignalSlotDispatcher ( \TYPO3\CMS\Extbase\SignalSlot\Dispatcher  $signalSlotDispatcher)
Parameters
\TYPO3\CMS\Extbase\SignalSlot\Dispatcher$signalSlotDispatcher

Definition at line 128 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\$signalSlotDispatcher.

◆ isPersistableProperty()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::isPersistableProperty (   $className,
  $propertyName 
)

Delegates the call to the Data Map. Returns TRUE if the property is persistable (configured in $TCA)

Parameters
string$classNameThe property name
string$propertyNameThe property name
Returns
bool TRUE if the property is persistable (configured in $TCA)

Definition at line 598 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap().

◆ map()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::map (   $className,
array  $rows 
)

Maps the given rows on objects

Parameters
string$classNameThe name of the class
array$rowsAn array of arrays with field_name => value pairs
Returns
array An array of objects of the given class

Definition at line 140 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getTargetType(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapSingleRow().

◆ mapCoreType()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapCoreType (   $type,
  $value 
)
protected

Map value to a core type

Parameters
string$type
mixed$value
Returns

Definition at line 310 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

◆ mapDateTime()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapDateTime (   $value,
  $storageFormat = null,
  $targetType = 'DateTime' 
)
protected

Creates a DateTime from an unix timestamp or date/datetime value. If the input is empty, NULL is returned.

Parameters
int | string$valueUnix timestamp or date/datetime value
NULL | string$storageFormatStorage format for native date/datetime fields
NULL | string$targetTypeThe object class name to be created
Returns

Definition at line 324 of file DataMapper.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

◆ mapObjectToClassProperty()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapObjectToClassProperty ( DomainObjectInterface  $parentObject,
  $propertyName,
  $fieldValue 
)
protected

Returns the mapped classProperty from the identiyMap or mapResultToPropertyValue()

If the field value is empty and the column map has no parent key field name, the relation will be empty. If the persistence session has a registered object of the correct type and identity (fieldValue), this function returns that object. Otherwise, it proceeds with mapResultToPropertyValue().

Parameters
DomainObjectInterface$parentObject
string$propertyName
mixed$fieldValuethe raw field value
Returns
mixed
See also
mapResultToPropertyValue()

Definition at line 499 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\fetchRelated(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getEmptyRelationValue(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapResultToPropertyValue(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\propertyMapsByForeignKey().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

◆ mapResultToPropertyValue()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapResultToPropertyValue ( DomainObjectInterface  $parentObject,
  $propertyName,
  $result 
)

Returns the given result as property value of the specified property type.

Parameters
DomainObjectInterface$parentObject
string$propertyName
mixed$resultThe result
Returns
mixed

Definition at line 542 of file DataMapper.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapObjectToClassProperty(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

◆ mapSingleRow()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapSingleRow (   $className,
array  $row 
)
protected

Maps a single row on an object of the given class

Parameters
string$classNameThe name of the target class
array$rowA single array with field_name => value pairs
Returns
object An object of the given class

Definition at line 179 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\createEmptyObject(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\emitAfterMappingSingleRow(), and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\thawProperties().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\map().

◆ propertyMapsByForeignKey()

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::propertyMapsByForeignKey ( DomainObjectInterface  $parentObject,
  $propertyName 
)
protected

Checks if the relation is based on a foreign key.

Parameters
DomainObjectInterface$parentObject
string$propertyName
Returns
bool TRUE if the property is mapped

Definition at line 528 of file DataMapper.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\getDataMap().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper\mapObjectToClassProperty().

◆ thawProperties()

Member Data Documentation

◆ $dataMapFactory

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$dataMapFactory
protected

◆ $dataMaps

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$dataMaps = []
protected

Definition at line 55 of file DataMapper.php.

◆ $objectManager

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$objectManager
protected

◆ $pageSelectObject

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$pageSelectObject
protected

Definition at line 48 of file DataMapper.php.

◆ $persistenceSession

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$persistenceSession
protected

◆ $qomFactory

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$qomFactory
protected

◆ $queryFactory

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$queryFactory
protected

◆ $reflectionService

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$reflectionService
protected

◆ $signalSlotDispatcher

TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::$signalSlotDispatcher
protected