‪TYPO3CMS  10.4
CoreTypeConverter.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 
31 {
35  protected ‪$sourceTypes = ['string', 'integer', 'float', 'boolean', 'array'];
36 
40  protected ‪$targetType = TypeInterface::class;
41 
45  protected ‪$priority = 10;
46 
53  public function ‪canConvertFrom($source, string ‪$targetType): bool
54  {
56  }
57 
68  public function ‪convertFrom($source, string ‪$targetType, array $convertedChildProperties = [], ‪PropertyMappingConfigurationInterface $configuration = null): object
69  {
70  try {
71  return new ‪$targetType($source);
72  } catch (‪InvalidValueExceptionInterface $exception) {
73  return new ‪Error($exception->getMessage(), 1381680012);
74  }
75  }
76 }
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter
Definition: CoreTypeConverter.php:31
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$targetType
‪string $targetType
Definition: CoreTypeConverter.php:38
‪TYPO3\CMS\Core\Type\Exception\InvalidValueExceptionInterface
Definition: InvalidValueExceptionInterface.php:22
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface
Definition: PropertyMappingConfigurationInterface.php:22
‪TYPO3\CMS\Extbase\Error\Error
Definition: Error.php:25
‪TYPO3\CMS\Extbase\Utility\TypeHandlingUtility
Definition: TypeHandlingUtility.php:29
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$sourceTypes
‪string[] $sourceTypes
Definition: CoreTypeConverter.php:34
‪TYPO3\CMS\Extbase\Property\TypeConverter
Definition: AbstractFileCollectionConverter.php:18
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\convertFrom
‪object convertFrom($source, string $targetType, array $convertedChildProperties=[], PropertyMappingConfigurationInterface $configuration=null)
Definition: CoreTypeConverter.php:65
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$priority
‪int $priority
Definition: CoreTypeConverter.php:42
‪TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCoreType
‪static bool isCoreType($type)
Definition: TypeHandlingUtility.php:124
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter
Definition: AbstractTypeConverter.php:34
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\canConvertFrom
‪bool canConvertFrom($source, string $targetType)
Definition: CoreTypeConverter.php:50
‪TYPO3\CMS\Core\Type\TypeInterface
Definition: TypeInterface.php:24