‪TYPO3CMS  9.5
CoreTypeConverter.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 
19 
25 {
29  protected ‪$sourceTypes = ['string', 'integer', 'float', 'boolean', 'array'];
30 
34  protected ‪$targetType = \TYPO3\CMS\Core\Type\TypeInterface::class;
35 
39  protected ‪$priority = 10;
40 
47  public function ‪canConvertFrom($source, ‪$targetType)
48  {
50  }
51 
62  public function ‪convertFrom($source, ‪$targetType, array $convertedChildProperties = [], \‪TYPO3\CMS\‪Extbase\Property\‪PropertyMappingConfigurationInterface $configuration = null)
63  {
64  try {
65  return new ‪$targetType($source);
66  } catch (‪InvalidValueExceptionInterface $exception) {
67  return new \TYPO3\CMS\Extbase\Error\Error($exception->getMessage(), 1381680012);
68  }
69  }
70 }
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter
Definition: CoreTypeConverter.php:25
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\canConvertFrom
‪bool canConvertFrom($source, $targetType)
Definition: CoreTypeConverter.php:44
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$targetType
‪string $targetType
Definition: CoreTypeConverter.php:32
‪TYPO3
‪TYPO3\CMS\Core\Type\Exception\InvalidValueExceptionInterface
Definition: InvalidValueExceptionInterface.php:21
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface
Definition: PropertyMappingConfigurationInterface.php:21
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\convertFrom
‪object convertFrom($source, $targetType, array $convertedChildProperties=[], \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration=null)
Definition: CoreTypeConverter.php:59
‪TYPO3\CMS\Extbase\Utility\TypeHandlingUtility
Definition: TypeHandlingUtility.php:19
‪TYPO3\CMS\Extbase\Property\TypeConverter
Definition: AbstractFileCollectionConverter.php:2
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$priority
‪int $priority
Definition: CoreTypeConverter.php:36
‪TYPO3\CMS\Extbase\Utility\TypeHandlingUtility\isCoreType
‪static bool isCoreType($type)
Definition: TypeHandlingUtility.php:114
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter
Definition: AbstractTypeConverter.php:26
‪TYPO3\CMS\Extbase\Property\TypeConverter\CoreTypeConverter\$sourceTypes
‪array< string > $sourceTypes
Definition: CoreTypeConverter.php:28