‪TYPO3CMS  10.4
EnhancerFactory.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 
21 
26 {
30  protected ‪$availableEnhancers;
31 
35  public function ‪__construct()
36  {
37  $this->availableEnhancers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['enhancers'] ?? [];
38  }
39 
47  public function ‪create(string $type, array $settings): ‪EnhancerInterface
48  {
49  if (empty($type)) {
50  throw new \InvalidArgumentException(
51  'Enhancer type cannot be empty',
52  1537298284
53  );
54  }
55  if (!isset($this->availableEnhancers[$type])) {
56  throw new \OutOfRangeException(
57  sprintf('No enhancer found for %s', $type),
58  1537277222
59  );
60  }
61  unset($settings['type']);
62  $className = $this->availableEnhancers[$type];
64  $enhancer = GeneralUtility::makeInstance($className, $settings);
65  return $enhancer;
66  }
67 }
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\$availableEnhancers
‪array $availableEnhancers
Definition: EnhancerFactory.php:29
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory
Definition: EnhancerFactory.php:26
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\__construct
‪__construct()
Definition: EnhancerFactory.php:34
‪TYPO3\CMS\Core\Routing\Enhancer
Definition: AbstractEnhancer.php:18
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\create
‪EnhancerInterface create(string $type, array $settings)
Definition: EnhancerFactory.php:46
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerInterface
Definition: EnhancerInterface.php:27