‪TYPO3CMS  10.4
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 
39  public function ‪__construct(‪SiteFinder ‪$siteFinder = null)
40  {
41  $this->siteFinder = ‪$siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
42  }
43 
50  public function ‪addData(array $result): array
51  {
52  if ($result['tableName'] === 'sys_redirect' && isset($result['processedTca']['columns']['source_host'])) {
53  $domains = $this->‪getHosts();
54  foreach ($domains as $domain) {
55  $result['processedTca']['columns']['source_host']['config']['valuePicker']['items'][] =
56  [
57  $domain,
58  $domain,
59  ];
60  }
61  }
62  return $result;
63  }
64 
70  protected function ‪getHosts(): array
71  {
72  $domains = [];
73  foreach ($this->siteFinder->getAllSites() as $site) {
74  foreach ($site->getAllLanguages() as $language) {
75  $domains[] = $language->getBase()->getHost();
76  }
77  }
78  $domains = array_unique($domains);
79  sort($domains, SORT_NATURAL);
80  return $domains;
81  }
82 }
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\addData
‪array addData(array $result)
Definition: ValuePickerItemDataProvider.php:49
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\getHosts
‪array getHosts()
Definition: ValuePickerItemDataProvider.php:69
‪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\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Redirects\FormDataProvider\ValuePickerItemDataProvider\__construct
‪__construct(SiteFinder $siteFinder=null)
Definition: ValuePickerItemDataProvider.php:38
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46