‪TYPO3CMS  10.4
AbstractFileFolderConverter.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 
32 {
36  protected ‪$priority = 10;
37 
41  protected ‪$expectedObjectType;
42 
46  protected ‪$fileFactory;
47 
52  {
53  $this->fileFactory = ‪$fileFactory;
54  }
55 
67  public function ‪convertFrom($source, string ‪$targetType, array $convertedChildProperties = [], ‪PropertyMappingConfigurationInterface $configuration = null): ‪AbstractFileFolder
68  {
69  $object = $this->‪getOriginalResource($source);
70  if (empty($this->expectedObjectType) || !$object instanceof $this->expectedObjectType) {
71  throw new ‪Exception('Expected object of type "' . $this->expectedObjectType . '" but got ' . (is_object($object) ? get_class($object) : 'null'), 1342895975);
72  }
74  $subject = $this->objectManager->get(‪$targetType);
75  $subject->setOriginalResource($object);
76  return $subject;
77  }
78 
83  abstract protected function ‪getOriginalResource($source): ?‪ResourceInterface;
84 }
‪TYPO3\CMS\Extbase\Property\Exception
Definition: DuplicateObjectException.php:18
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\convertFrom
‪TYPO3 CMS Extbase Domain Model AbstractFileFolder convertFrom($source, string $targetType, array $convertedChildProperties=[], PropertyMappingConfigurationInterface $configuration=null)
Definition: AbstractFileFolderConverter.php:64
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\injectFileFactory
‪injectFileFactory(ResourceFactory $fileFactory)
Definition: AbstractFileFolderConverter.php:48
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface
Definition: PropertyMappingConfigurationInterface.php:22
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\$priority
‪int $priority
Definition: AbstractFileFolderConverter.php:35
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\$fileFactory
‪TYPO3 CMS Core Resource ResourceFactory $fileFactory
Definition: AbstractFileFolderConverter.php:43
‪TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder
Definition: AbstractFileFolder.php:27
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter\$targetType
‪string $targetType
Definition: AbstractTypeConverter.php:45
‪TYPO3\CMS\Extbase\Property\TypeConverter
Definition: AbstractFileCollectionConverter.php:18
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Extbase\Property\Exception
Definition: Exception.php:26
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter
Definition: AbstractFileFolderConverter.php:32
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter
Definition: AbstractTypeConverter.php:34
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\getOriginalResource
‪TYPO3 CMS Core Resource ResourceInterface null getOriginalResource($source)
‪TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFileFolderConverter\$expectedObjectType
‪string $expectedObjectType
Definition: AbstractFileFolderConverter.php:39
‪TYPO3\CMS\Core\Resource\ResourceInterface
Definition: ResourceInterface.php:22