‪TYPO3CMS  11.5
RequestHandlersConfigurationFactory.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 use TYPO3\CMS\Core\Package\PackageManager;
23 
28 {
30 
31  private PackageManager ‪$packageManager;
32 
33  private string ‪$cacheIdentifier;
34 
36  {
37  $this->cache = ‪$cache;
38  $this->packageManager = ‪$packageManager;
39  $this->cacheIdentifier = ‪$cacheIdentifier;
40  }
41 
47  {
48  $requestHandlersCache = $this->cache->get($this->cacheIdentifier);
49  if ($requestHandlersCache) {
50  return new ‪RequestHandlersConfiguration($requestHandlersCache);
51  }
52 
53  $classes = [];
54  foreach ($this->packageManager->getActivePackages() as $activePackage) {
55  $requestHandlersFile = $activePackage->getPackagePath() . 'Configuration/Extbase/RequestHandlers.php';
56  if (file_exists($requestHandlersFile)) {
57  $definedClasses = require $requestHandlersFile;
58  if (!is_array($definedClasses)) {
59  continue;
60  }
61 
62  foreach ($definedClasses as $definedClass) {
63  if (!class_exists($definedClass)) {
64  throw new ‪Exception(
65  sprintf(
66  'Request class "%s", registered in "%s", does not exist.',
67  $definedClass,
68  $requestHandlersFile
69  ),
70  1562253559
71  );
72  }
73 
74  if (!in_array(RequestHandlerInterface::class, class_implements($definedClass), true)) {
75  throw new ‪Exception(
76  sprintf(
77  'Request class "%s", registered in "%s", does not implement interface "%s".',
78  $definedClass,
79  $requestHandlersFile,
80  RequestHandlerInterface::class
81  ),
82  1562257073
83  );
84  }
85 
86  $classes[] = $definedClass;
87  }
88  }
89  }
90 
91  $this->cache->set($this->cacheIdentifier, $classes);
92 
93  return new ‪RequestHandlersConfiguration($classes);
94  }
95 }
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory
Definition: RequestHandlersConfigurationFactory.php:28
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory\$packageManager
‪PackageManager $packageManager
Definition: RequestHandlersConfigurationFactory.php:31
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory\__construct
‪__construct(FrontendInterface $cache, PackageManager $packageManager, string $cacheIdentifier)
Definition: RequestHandlersConfigurationFactory.php:35
‪TYPO3\CMS\Extbase\Configuration\Exception
Definition: Exception.php:25
‪TYPO3\CMS\Extbase\Mvc\RequestHandlerInterface
Definition: RequestHandlerInterface.php:24
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfiguration
Definition: RequestHandlersConfiguration.php:24
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory\$cacheIdentifier
‪string $cacheIdentifier
Definition: RequestHandlersConfigurationFactory.php:33
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory\$cache
‪FrontendInterface $cache
Definition: RequestHandlersConfigurationFactory.php:29
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Extbase\Configuration
Definition: AbstractConfigurationManager.php:18
‪TYPO3\CMS\Extbase\Configuration\RequestHandlersConfigurationFactory\createRequestHandlersConfiguration
‪RequestHandlersConfiguration createRequestHandlersConfiguration()
Definition: RequestHandlersConfigurationFactory.php:46