‪TYPO3CMS  10.4
ProcessorRegistry.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 
23 
28 {
32  protected ‪$registeredProcessors = [];
33 
37  public function ‪__construct()
38  {
39  $this->registeredProcessors = GeneralUtility::makeInstance(DependencyOrderingService::class)
40  ->orderByDependencies($this->‪getRegisteredProcessors());
41  }
42 
51  {
52  $processor = null;
53 
54  foreach ($this->registeredProcessors as $key => $processorConfiguration) {
55  if (!isset($processorConfiguration['className'])) {
56  throw new \RuntimeException(
57  'Missing key "className" for processor configuration "' . $key . '".',
58  1560875741
59  );
60  }
61 
62  $processor = GeneralUtility::makeInstance($processorConfiguration['className']);
63 
64  if (!$processor instanceof ‪ProcessorInterface) {
65  throw new \RuntimeException(
66  'Processor "' . get_class($processor) . '" needs to implement interface "' . ProcessorInterface::class . '".',
67  1560876288
68  );
69  }
70 
71  if ($processor->canProcessTask($task)) {
72  /*
73  * Stop checking for further processors to speed up image processing.
74  * If another processor should be used, it can be registered with higher priority.
75  */
76  break;
77  }
78 
79  $processor = null;
80  }
81 
82  if ($processor === null) {
83  throw new \RuntimeException(
84  sprintf('No matching file processor found for task type "%s" and name "%s".', $task->‪getType(), $task->‪getName()),
85  1560876294
86  );
87  }
88 
89  return $processor;
90  }
91 
95  protected function ‪getRegisteredProcessors(): array
96  {
97  return ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] ?? [];
98  }
99 }
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getType
‪string getType()
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry\getRegisteredProcessors
‪array getRegisteredProcessors()
Definition: ProcessorRegistry.php:94
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface
Definition: TaskInterface.php:33
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry\$registeredProcessors
‪array $registeredProcessors
Definition: ProcessorRegistry.php:31
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry\getProcessorByTask
‪ProcessorInterface getProcessorByTask(TaskInterface $task)
Definition: ProcessorRegistry.php:49
‪TYPO3\CMS\Core\Resource\Processing
Definition: AbstractGraphicalTask.php:16
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry\__construct
‪__construct()
Definition: ProcessorRegistry.php:36
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getName
‪string getName()
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\Processing\ProcessorRegistry
Definition: ProcessorRegistry.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Processing\ProcessorInterface
Definition: ProcessorInterface.php:22