81 return !is_subclass_of(
$targetType,
'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractDomainObject');
91 if (isset($source[
'__type'])) {
92 unset($source[
'__type']);
107 $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(
'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\ObjectConverter', self::CONFIGURATION_TARGET_TYPE);
108 if ($configuredTargetType !== NULL) {
109 return $configuredTargetType;
112 $specificTargetType = $this->objectContainer->getImplementationClassName(
$targetType);
113 if ($this->reflectionService->hasMethod($specificTargetType, \
TYPO3\CMS\Extbase\Reflection\ObjectAccess::buildSetterMethodName($propertyName))) {
114 $methodParameters = $this->reflectionService->getMethodParameters($specificTargetType, \
TYPO3\CMS\Extbase\Reflection\ObjectAccess::buildSetterMethodName($propertyName));
115 $methodParameter = current($methodParameters);
116 if (!isset($methodParameter[
'type'])) {
117 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException(
'Setter for property "' . $propertyName .
'" had no type hint or documentation in target object of type "' . $specificTargetType .
'".', 1303379158);
119 return $methodParameter[
'type'];
122 $methodParameters = $this->reflectionService->getMethodParameters($specificTargetType,
'__construct');
123 if (isset($methodParameters[$propertyName]) && isset($methodParameters[$propertyName][
'type'])) {
124 return $methodParameters[$propertyName][
'type'];
126 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException(
'Property "' . $propertyName .
'" had no setter or constructor argument in target object of type "' . $specificTargetType .
'".', 1303379126);
145 foreach ($convertedChildProperties as $propertyName => $propertyValue) {
148 $exceptionMessage = sprintf(
149 'Property "%s" having a value of type "%s" could not be set in target object of type "%s". Make sure that the property is accessible properly, for example via an appropriate setter method.',
151 (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)),
154 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException($exceptionMessage, 1304538165);
175 if (is_array($source) && array_key_exists(
'__type', $source)) {
178 if ($configuration === NULL) {
179 throw new \InvalidArgumentException(
'A property mapping configuration must be given, not NULL.', 1326277369);
181 if ($configuration->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\ObjectConverter', self::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED) !== TRUE) {
182 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException(
'Override of target type not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED" to TRUE.', 1317050430);
186 if (version_compare(phpversion(),
'5.3.8',
'>')) {
188 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException(
'The given type "' .
$targetType .
'" is not a subtype of "' . $originalTargetType .
'".', 1317048056);
208 protected function buildObject(array &$possibleConstructorArgumentValues, $objectType) {
209 $specificObjectType = $this->objectContainer->getImplementationClassName($objectType);
210 if ($this->reflectionService->hasMethod($specificObjectType,
'__construct')) {
211 $constructorSignature = $this->reflectionService->getMethodParameters($specificObjectType,
'__construct');
212 $constructorArguments = array();
213 foreach ($constructorSignature as $constructorArgumentName => $constructorArgumentInformation) {
214 if (array_key_exists($constructorArgumentName, $possibleConstructorArgumentValues)) {
215 $constructorArguments[] = $possibleConstructorArgumentValues[$constructorArgumentName];
216 unset($possibleConstructorArgumentValues[$constructorArgumentName]);
217 } elseif ($constructorArgumentInformation[
'optional'] === TRUE) {
218 $constructorArguments[] = $constructorArgumentInformation[
'defaultValue'];
220 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException(
'Missing constructor argument "' . $constructorArgumentName .
'" for object of type "' . $objectType .
'".', 1268734872);
223 return call_user_func_array(array($this->objectManager,
'get'), array_merge(array($objectType), $constructorArguments));
225 return $this->objectManager->get($objectType);
241 if ($targetTypeToCompare === $originalTargetType) {
244 }
while ($targetTypeToCompare = get_parent_class($targetTypeToCompare));
246 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidDataTypeException(
'The given type "' .
$targetType .
'" is not a subtype of "' . $originalTargetType .
'".', 1360928582);
convertFrom($source, $targetType, array $convertedChildProperties=array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration=NULL)
getTargetTypeForSource($source, $originalTargetType, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration=NULL)
const CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED
canConvertFrom($source, $targetType)
checkInheritanceChainWithoutIsA($targetType, $originalTargetType)
getSourceChildPropertiesToBeConverted($source)
getTypeOfChildProperty($targetType, $propertyName, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration)
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.
static setProperty(&$subject, $propertyName, $propertyValue, $forceDirectAccess=FALSE)
const CONFIGURATION_TARGET_TYPE
buildObject(array &$possibleConstructorArgumentValues, $objectType)