‪TYPO3CMS  9.5
ObjectStorageConverter.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 {
27  protected ‪$sourceTypes = ['string', 'array'];
28 
32  protected ‪$targetType = \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class;
33 
37  protected ‪$priority = 10;
38 
49  public function ‪convertFrom($source, ‪$targetType, array $convertedChildProperties = [], \‪TYPO3\CMS\‪Extbase\Property\‪PropertyMappingConfigurationInterface $configuration = null)
50  {
51  $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
52  foreach ($convertedChildProperties as $subProperty) {
53  $objectStorage->attach($subProperty);
54  }
55  return $objectStorage;
56  }
57 
64  public function ‪getSourceChildPropertiesToBeConverted($source)
65  {
66  if (is_array($source)) {
67  return $source;
68  }
69  return [];
70  }
71 
80  public function ‪getTypeOfChildProperty(‪$targetType, $propertyName, \‪TYPO3\CMS\‪Extbase\Property\‪PropertyMappingConfigurationInterface $configuration)
81  {
83  return $parsedTargetType['elementType'];
84  }
85 }
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter
Definition: ObjectStorageConverter.php:23
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\convertFrom
‪TYPO3 CMS Extbase Persistence ObjectStorage convertFrom($source, $targetType, array $convertedChildProperties=[], \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration=null)
Definition: ObjectStorageConverter.php:46
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\getSourceChildPropertiesToBeConverted
‪array getSourceChildPropertiesToBeConverted($source)
Definition: ObjectStorageConverter.php:61
‪TYPO3
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface
Definition: PropertyMappingConfigurationInterface.php:21
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\getTypeOfChildProperty
‪string getTypeOfChildProperty($targetType, $propertyName, \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration)
Definition: ObjectStorageConverter.php:77
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\$sourceTypes
‪array< string > $sourceTypes
Definition: ObjectStorageConverter.php:26
‪TYPO3\CMS\Extbase\Property\TypeConverter
Definition: AbstractFileCollectionConverter.php:2
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter
Definition: AbstractTypeConverter.php:26
‪TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\parseType
‪static array parseType($type)
Definition: TypeHandlingUtility.php:42
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\$priority
‪int $priority
Definition: ObjectStorageConverter.php:34
‪TYPO3\CMS\Extbase\Property\TypeConverter\ObjectStorageConverter\$targetType
‪string $targetType
Definition: ObjectStorageConverter.php:30