‪TYPO3CMS  ‪main
PageDoktypeProvider.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 
24 {
25  public function ‪__construct(protected readonly ‪PageDoktypeRegistry $doktypeRegistry) {}
26 
27  public function ‪getConfiguration(): array
28  {
29  $configuration = [];
30  $languageService = $this->‪getLanguageService();
31  $allLabels = $this->‪prepareLabelsForAllTypes();
32  $providerConfiguration = $this->doktypeRegistry->exportConfiguration();
33  ksort($providerConfiguration);
34  foreach ($providerConfiguration as $pageType => $typeConfiguration) {
35  if (isset($allLabels[$pageType])) {
36  $configuration[$pageType] = array_merge_recursive(['name' => $languageService->sL($allLabels[$pageType])], $typeConfiguration);
37  } else {
38  $configuration[$pageType] = $typeConfiguration;
39  }
40  }
41  return $configuration;
42  }
43 
44  protected function ‪prepareLabelsForAllTypes(): array
45  {
46  $types = [];
47  foreach (‪$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'] as $item) {
48  if (‪MathUtility::canBeInterpretedAsInteger($item['value'])) {
49  $types[(int)$item['value']] = $item['label'];
50  }
51  }
52  return $types;
53  }
54 }
‪TYPO3\CMS\Core\DataHandling\PageDoktypeRegistry
Definition: PageDoktypeRegistry.php:35
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\AbstractProvider\getLanguageService
‪getLanguageService()
Definition: AbstractProvider.php:52
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\AbstractProvider
Definition: AbstractProvider.php:27
‪TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger
‪static bool canBeInterpretedAsInteger(mixed $var)
Definition: MathUtility.php:69
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\PageDoktypeProvider\getConfiguration
‪getConfiguration()
Definition: PageDoktypeProvider.php:27
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\PageDoktypeProvider
Definition: PageDoktypeProvider.php:24
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider
Definition: AbstractProvider.php:18
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:24
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\PageDoktypeProvider\prepareLabelsForAllTypes
‪prepareLabelsForAllTypes()
Definition: PageDoktypeProvider.php:44
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\PageDoktypeProvider\__construct
‪__construct(protected readonly PageDoktypeRegistry $doktypeRegistry)
Definition: PageDoktypeProvider.php:25