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