‪TYPO3CMS  10.4
SiteResolving.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 
26 
35 {
39  protected ‪$siteFinder;
40 
41  public function ‪__construct(‪SiteFinder ‪$siteFinder = null)
42  {
43  $this->siteFinder = ‪$siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
44  }
45 
52  public function ‪addData(array $result): array
53  {
54  if ($result['defaultLanguagePageRow']['t3ver_oid'] ?? null) {
55  $pageIdDefaultLanguage = (int)$result['defaultLanguagePageRow']['t3ver_oid'];
56  } elseif ($result['defaultLanguagePageRow']['uid'] ?? null) {
57  $pageIdDefaultLanguage = (int)$result['defaultLanguagePageRow']['uid'];
58  } elseif (array_key_exists('tableName', $result) && $result['tableName'] === 'pages') {
59  if (!empty($result['databaseRow']['t3ver_oid'])) {
60  $pageIdDefaultLanguage = $result['databaseRow']['t3ver_oid'];
61  } else {
62  $pageIdDefaultLanguage = $result['databaseRow']['uid'] ?? $result['effectivePid'];
63  }
64  } else {
65  $pageIdDefaultLanguage = $result['effectivePid'];
66  }
67  $result['site'] = $this->‪resolveSite((int)$pageIdDefaultLanguage);
68  return $result;
69  }
70 
75  protected function ‪resolveSite(int $pageId): SiteInterface
76  {
77  try {
78  return $this->siteFinder->getSiteByPageId($pageId);
79  } catch (SiteNotFoundException $e) {
80  return new NullSite();
81  }
82  }
83 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:26
‪TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving
Definition: SiteResolving.php:35
‪TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving\addData
‪array addData(array $result)
Definition: SiteResolving.php:51
‪TYPO3\CMS\Core\Site\Entity\NullSite
Definition: NullSite.php:32
‪TYPO3\CMS\Core\Exception\SiteNotFoundException
Definition: SiteNotFoundException.php:26
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving\__construct
‪__construct(SiteFinder $siteFinder=null)
Definition: SiteResolving.php:40
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving\$siteFinder
‪SiteFinder $siteFinder
Definition: SiteResolving.php:38
‪TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving\resolveSite
‪SiteInterface resolveSite(int $pageId)
Definition: SiteResolving.php:74
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46