‪TYPO3CMS  10.4
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 
21 use TYPO3\CMS\Core\Package\PackageManager;
23 
29 {
33  protected ‪$cacheIdentifier = 'expressionLanguageProviders';
34 
39  public function ‪getExpressionLanguageProviders(): array
40  {
41  $packageManager = GeneralUtility::makeInstance(PackageManager::class);
42  $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('core');
43 
45  $providers = $cache->require($this->cacheIdentifier);
46  if ($providers !== false) {
47  return $providers;
48  }
49 
50  $packages = $packageManager->getActivePackages();
51  $providers = [];
52  foreach ($packages as $package) {
53  $packageConfiguration = $package->getPackagePath() . 'Configuration/ExpressionLanguage.php';
54  if (file_exists($packageConfiguration)) {
55  $providersInPackage = require $packageConfiguration;
56  if (is_array($providersInPackage)) {
57  $providers[] = $providersInPackage;
58  }
59  }
60  }
61  $providers = count($providers) > 0 ? array_merge_recursive(...$providers) : $providers;
62  $cache->set($this->cacheIdentifier, 'return ' . var_export($providers, true) . ';');
63  return $providers ?? [];
64  }
65 }
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\$cacheIdentifier
‪string $cacheIdentifier
Definition: ProviderConfigurationLoader.php:32
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader\getExpressionLanguageProviders
‪array getExpressionLanguageProviders()
Definition: ProviderConfigurationLoader.php:38
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:35
‪TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader
Definition: ProviderConfigurationLoader.php:29
‪TYPO3\CMS\Core\ExpressionLanguage
Definition: AbstractProvider.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46