TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PropertyMapper Class Reference
Inheritance diagram for PropertyMapper:
SingletonInterface

Public Member Functions

 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 injectConfigurationBuilder (\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder $configurationBuilder)
 
 initializeObject ()
 
 convert ($source, $targetType, PropertyMappingConfigurationInterface $configuration=null)
 
 getMessages ()
 
 parseCompositeType ($compositeType)
 

Protected Member Functions

 doMapping ($source, $targetType, PropertyMappingConfigurationInterface $configuration, &$currentPropertyPath)
 
 findTypeConverter ($source, $targetType, PropertyMappingConfigurationInterface $configuration)
 
 findFirstEligibleTypeConverterInObjectHierarchy ($source, $sourceType, $targetClass)
 
 getConvertersForInterfaces (array $convertersForSource, array $interfaceNames)
 
 determineSourceType ($source)
 

Protected Attributes

 $objectManager
 
 $configurationBuilder
 
 $typeConverters = array()
 
 $messages
 

Detailed Description

The Property Mapper transforms simple types (arrays, strings, integers, floats, booleans) to objects or other simple types. It is used most prominently to map incoming HTTP arguments to objects.

http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later

Definition at line 34 of file PropertyMapper.php.

Member Function Documentation

convert (   $source,
  $targetType,
PropertyMappingConfigurationInterface  $configuration = null 
)

Map $source to $targetType, and return the result

Parameters
mixed$sourcethe source data to map. MUST be a simple type, NO object allowed!
string$targetTypeThe type of the target; can be either a class name or a simple type.
PropertyMappingConfigurationInterface$configurationConfiguration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
Exceptions
Exception
Returns
mixed an instance of $targetType

Definition at line 111 of file PropertyMapper.php.

References PropertyMapper\doMapping().

determineSourceType (   $source)
protected

Determine the type of the source data, or throw an exception if source was an unsupported format.

Parameters
mixed$source
Exceptions
Exception\InvalidSourceException
Returns
string the type of $source

Definition at line 356 of file PropertyMapper.php.

References elseif.

doMapping (   $source,
  $targetType,
PropertyMappingConfigurationInterface  $configuration,
$currentPropertyPath 
)
protected

Internal function which actually does the property mapping.

Parameters
mixed$sourcethe source data to map. MUST be a simple type, NO object allowed!
string$targetTypeThe type of the target; can be either a class name or a simple type.
PropertyMappingConfigurationInterface$configurationConfiguration for the property mapping.
array&$currentPropertyPathThe property path currently being mapped; used for knowing the context in case an exception is thrown.
Exceptions
Exception\TypeConverterException
Exception\InvalidPropertyMappingConfigurationException
Returns
mixed an instance of $targetType

Definition at line 154 of file PropertyMapper.php.

References PropertyMapper\findTypeConverter(), PropertyMappingConfigurationInterface\getTargetPropertyName(), PropertyMapper\parseCompositeType(), PropertyMappingConfigurationInterface\shouldSkip(), and PropertyMappingConfigurationInterface\shouldSkipUnknownProperties().

Referenced by PropertyMapper\convert().

findFirstEligibleTypeConverterInObjectHierarchy (   $source,
  $sourceType,
  $targetClass 
)
protected

Tries to find a suitable type converter for the given source and target type.

Parameters
string$sourceThe actual source value
string$sourceTypeType of the source to convert from
string$targetClassName of the target class to find a type converter for
Returns
mixed Either the matching object converter or NULL
Exceptions
Exception\InvalidTargetException

Definition at line 263 of file PropertyMapper.php.

findTypeConverter (   $source,
  $targetType,
PropertyMappingConfigurationInterface  $configuration 
)
protected

Determine the type converter to be used. If no converter has been found, an exception is raised.

Parameters
mixed$source
string$targetType
PropertyMappingConfigurationInterface$configuration
Exceptions
Exception\TypeConverterException
Exception\InvalidTargetException
Returns
Type Converter which should be used to convert between $source and $targetType.

Definition at line 218 of file PropertyMapper.php.

Referenced by PropertyMapper\doMapping().

getConvertersForInterfaces ( array  $convertersForSource,
array  $interfaceNames 
)
protected
Parameters
array$convertersForSource
array$interfaceNames
Returns
array
Exceptions
Exception\DuplicateTypeConverterException

Definition at line 333 of file PropertyMapper.php.

getMessages ( )

Get the messages of the last Property Mapping

Returns

Definition at line 138 of file PropertyMapper.php.

References PropertyMapper\$messages.

initializeObject ( )

Lifecycle method, called after all dependencies have been injected. Here, the typeConverter array gets initialized.

Exceptions
Exception\DuplicateTypeConverterException
Returns
void

Definition at line 88 of file PropertyMapper.php.

References $GLOBALS.

injectConfigurationBuilder ( \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder  $configurationBuilder)
Parameters
\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder$configurationBuilder

Definition at line 76 of file PropertyMapper.php.

References PropertyMapper\$configurationBuilder.

injectObjectManager ( \TYPO3\CMS\Extbase\Object\ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager

Definition at line 68 of file PropertyMapper.php.

References PropertyMapper\$objectManager.

parseCompositeType (   $compositeType)

Parse a composite type like <> into

Parameters
string$compositeType
Returns
string

Definition at line 380 of file PropertyMapper.php.

Referenced by PropertyMapper\doMapping().

Member Data Documentation

$configurationBuilder
protected

Definition at line 44 of file PropertyMapper.php.

Referenced by PropertyMapper\injectConfigurationBuilder().

$messages
protected

Definition at line 63 of file PropertyMapper.php.

Referenced by PropertyMapper\getMessages().

$objectManager
protected

Definition at line 39 of file PropertyMapper.php.

Referenced by PropertyMapper\injectObjectManager().

$typeConverters = array()
protected

Definition at line 56 of file PropertyMapper.php.