‪TYPO3CMS  ‪main
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 
44  public function ‪create(string $type, array $settings): ‪EnhancerInterface
45  {
46  if (empty($type)) {
47  throw new \InvalidArgumentException(
48  'Enhancer type cannot be empty',
49  1537298284
50  );
51  }
52  if (!isset($this->availableEnhancers[$type])) {
53  throw new \OutOfRangeException(
54  sprintf('No enhancer found for %s', $type),
55  1537277222
56  );
57  }
58  unset($settings['type']);
59  $className = $this->availableEnhancers[$type];
61  $enhancer = GeneralUtility::makeInstance($className, $settings);
62  return $enhancer;
63  }
64 }
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\$availableEnhancers
‪array $availableEnhancers
Definition: EnhancerFactory.php:29
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerFactory\create
‪create(string $type, array $settings)
Definition: EnhancerFactory.php:43
‪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
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Routing\Enhancer\EnhancerInterface
Definition: EnhancerInterface.php:27