‪TYPO3CMS  11.5
ValuePickerItemDataProvider.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 
29 {
33  protected ‪$siteFinder;
34 
35  public function ‪__construct(‪SiteFinder ‪$siteFinder = null)
36  {
37  $this->siteFinder = ‪$siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
38  }
39 
46  public function ‪addData(array $result): array
47  {
48  if ($result['tableName'] === 'sys_redirect' && isset($result['processedTca']['columns']['source_host'])) {
49  $domains = $this->‪getHosts();
50  foreach ($domains as $domain) {
51  $result['processedTca']['columns']['source_host']['config']['valuePicker']['items'][] =
52  [
53  $domain,
54  $domain,
55  ];
56  }
57  }
58  return $result;
59  }
60 
66  protected function ‪getHosts(): array
67  {
68  $domains = [];
69  foreach ($this->siteFinder->getAllSites() as $site) {
70  foreach ($site->getAllLanguages() as $language) {
71  $domains[] = $language->getBase()->getHost();
72  }
73  }
74  $domains = array_unique($domains);
75  sort($domains, SORT_NATURAL);
76  return $domains;
77  }
78 }
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\addData
‪array addData(array $result)
Definition: ValuePickerItemDataProvider.php:45
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\$siteFinder
‪SiteFinder $siteFinder
Definition: ValuePickerItemDataProvider.php:32
‪TYPO3\CMS\Redirects\FormDataProvider
Definition: ValuePickerItemDataProvider.php:18
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider
Definition: ValuePickerItemDataProvider.php:29
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\getHosts
‪string[] getHosts()
Definition: ValuePickerItemDataProvider.php:65
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\__construct
‪__construct(SiteFinder $siteFinder=null)
Definition: ValuePickerItemDataProvider.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50