‪TYPO3CMS  ‪main
ProviderConfigurationLoader.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 use TYPO3\CMS\Core\Package\PackageManager;
24 
29 {
30  public function ‪__construct(
31  private readonly PackageManager $packageManager,
32  private readonly ‪PhpFrontend $coreCache,
33  private readonly string $cacheIdentifier,
34  ) {}
35 
36  public function ‪getExpressionLanguageProviders(): array
37  {
38  $providers = $this->coreCache->require($this->cacheIdentifier);
39  if ($providers !== false) {
40  return $providers;
41  }
42 
43  return $this->‪createCache();
44  }
45 
46  private function ‪createCache(): array
47  {
48  $packages = $this->packageManager->getActivePackages();
49  $providers = [];
50  foreach ($packages as $package) {
51  $packageConfiguration = $package->getPackagePath() . 'Configuration/ExpressionLanguage.php';
52  if (file_exists($packageConfiguration)) {
53  $providersInPackage = require $packageConfiguration;
54  if (is_array($providersInPackage)) {
55  $providers[] = $providersInPackage;
56  }
57  }
58  }
59  $providers = count($providers) > 0 ? array_merge_recursive(...$providers) : $providers;
60  $this->coreCache->set($this->cacheIdentifier, 'return ' . var_export($providers, true) . ';');
61  return $providers;
62  }
63 
67  #[AsEventListener]
68  public function ‪warmupCaches(‪CacheWarmupEvent $event): void
69  {
70  if ($event->‪hasGroup('system')) {
71  $this->‪createCache();
72  }
73  }
74 }
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\__construct
‪__construct(private readonly PackageManager $packageManager, private readonly PhpFrontend $coreCache, private readonly string $cacheIdentifier,)
Definition: ProviderConfigurationLoader.php:30
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\getExpressionLanguageProviders
‪getExpressionLanguageProviders()
Definition: ProviderConfigurationLoader.php:36
‪TYPO3\CMS\Core\Attribute\AsEventListener
Definition: AsEventListener.php:25
‪TYPO3\CMS\Core\Cache\Frontend\PhpFrontend
Definition: PhpFrontend.php:25
‪TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent
Definition: CacheWarmupEvent.php:24
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\createCache
‪createCache()
Definition: ProviderConfigurationLoader.php:46
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader
Definition: ProviderConfigurationLoader.php:29
‪TYPO3\CMS\Core\ExpressionLanguage
Definition: AbstractProvider.php:18
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\warmupCaches
‪warmupCaches(CacheWarmupEvent $event)
Definition: ProviderConfigurationLoader.php:68
‪TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent\hasGroup
‪hasGroup(string $group)
Definition: CacheWarmupEvent.php:34