2 namespace TYPO3\CMS\Extbase\Property\TypeConverter;
86 return is_subclass_of(
$targetType, \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject::class);
97 if (is_string($source) || is_int($source)) {
100 if (isset($source[
'__identity'])) {
101 unset($source[
'__identity']);
103 return parent::getSourceChildPropertiesToBeConverted($source);
117 $configuredTargetType = $configuration->getConfigurationFor($propertyName)->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_TARGET_TYPE);
118 if ($configuredTargetType !== null) {
119 return $configuredTargetType;
122 $specificTargetType = $this->objectContainer->getImplementationClassName(
$targetType);
123 $schema = $this->reflectionService->getClassSchema($specificTargetType);
124 if (!$schema->hasProperty($propertyName)) {
125 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException(
'Property "' . $propertyName .
'" was not found in target object of type "' . $specificTargetType .
'".', 1297978366);
127 $propertyInformation = $schema->getProperty($propertyName);
128 return $propertyInformation[
'type'] . ($propertyInformation[
'elementType'] !== null ?
'<' . $propertyInformation[
'elementType'] .
'>' :
'');
144 if (is_array($source)) {
147 && is_subclass_of(
$targetType, \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject::class)
151 unset($source[
'__identity']);
154 }
elseif (is_string($source) || is_int($source)) {
155 if (empty($source)) {
160 throw new \InvalidArgumentException(
'Only integers, strings and arrays are accepted.', 1305630314);
162 foreach ($convertedChildProperties as $propertyName => $propertyValue) {
163 $result = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($object, $propertyName, $propertyValue);
164 if ($result ===
false) {
165 $exceptionMessage = sprintf(
166 '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.',
168 (is_object($propertyValue) ? get_class($propertyValue) : gettype($propertyValue)),
171 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException($exceptionMessage, 1297935345);
190 if (isset($source[
'__identity'])) {
193 if (count($source) > 1 && ($configuration === null || $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_MODIFICATION_ALLOWED) !==
true)) {
194 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException(
'Modification of persistent objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_MODIFICATION_ALLOWED" to TRUE.', 1297932028);
197 if ($configuration === null || $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, self::CONFIGURATION_CREATION_ALLOWED) !==
true) {
198 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidPropertyMappingConfigurationException(
'Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE');
216 if (ctype_digit((
string)$identity)) {
217 $object = $this->persistenceManager->getObjectByIdentifier($identity,
$targetType);
219 throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidSourceException(
'The identity property "' . $identity .
'" is no UID.', 1297931020);
222 if ($object === null) {
223 throw new \TYPO3\CMS\Extbase\Property\Exception\TargetNotFoundException(sprintf(
'Object of type %s with identity "%s" not found.',
$targetType, print_r($identity,
true)), 1297933823);