‪TYPO3CMS  9.5
EnhancerFactory.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
20 
25 {
29  protected ‪$availableEnhancers;
30 
34  public function ‪__construct()
35  {
36  $this->availableEnhancers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['routing']['enhancers'] ?? [];
37  }
38 
46  public function ‪create(string $type, array $settings): ‪EnhancerInterface
47  {
48  if (empty($type)) {
49  throw new \InvalidArgumentException(
50  'Enhancer type cannot be empty',
51  1537298284
52  );
53  }
54  if (!isset($this->availableEnhancers[$type])) {
55  throw new \OutOfRangeException(
56  sprintf('No enhancer found for %s', $type),
57  1537277222
58  );
59  }
60  unset($settings['type']);
61  $className = $this->availableEnhancers[$type];
63  $enhancer = GeneralUtility::makeInstance($className, $settings);
64  return $enhancer;
65  }
66 }
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\$availableEnhancers
‪array $availableEnhancers
Definition: EnhancerFactory.php:28
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory
Definition: EnhancerFactory.php:25
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\__construct
‪__construct()
Definition: EnhancerFactory.php:33
‪TYPO3\CMS\Core\Routing\Enhancer
Definition: AbstractEnhancer.php:4
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\create
‪EnhancerInterface create(string $type, array $settings)
Definition: EnhancerFactory.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerInterface
Definition: EnhancerInterface.php:26