‪TYPO3CMS  9.5
SiteProcessor.php
Go to the documentation of this file.
1 <?php
2 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 
24 
38 {
39 
47  public function ‪process(‪ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData): array
48  {
49  $targetVariableName = $cObj->‪stdWrapValue('as', $processorConfiguration, 'site');
50  $processedData[$targetVariableName] = $this->‪getCurrentSite();
51  return $processedData;
52  }
53 
59  protected function ‪getCurrentSite(): ?‪SiteInterface
60  {
61  try {
62  return $this->‪getMatcher()->‪matchByPageId($this->‪getCurrentPageId());
63  } catch (‪SiteNotFoundException $e) {
64  // Do nothing
65  }
66 
67  return null;
68  }
69 
73  protected function ‪getMatcher(): ‪SiteMatcher
74  {
75  return GeneralUtility::makeInstance(SiteMatcher::class);
76  }
77 
81  protected function ‪getCurrentPageId(): int
82  {
83  return (int)‪$GLOBALS['TSFE']->id;
84  }
85 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:25
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor
Definition: SiteProcessor.php:38
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor\getCurrentPageId
‪int getCurrentPageId()
Definition: SiteProcessor.php:81
‪TYPO3\CMS\Core\Exception\SiteNotFoundException
Definition: SiteNotFoundException.php:25
‪TYPO3\CMS\Frontend\DataProcessing
Definition: CommaSeparatedValueProcessor.php:2
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor\getCurrentSite
‪SiteInterface null getCurrentSite()
Definition: SiteProcessor.php:59
‪TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface
Definition: DataProcessorInterface.php:22
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrapValue
‪string stdWrapValue($key, array $config, $defaultValue='')
Definition: ContentObjectRenderer.php:1637
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor\getMatcher
‪SiteMatcher getMatcher()
Definition: SiteProcessor.php:73
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:91
‪TYPO3\CMS\Core\Routing\SiteMatcher\matchByPageId
‪SiteInterface matchByPageId(int $pageId, array $rootLine=null)
Definition: SiteMatcher.php:221
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Routing\SiteMatcher
Definition: SiteMatcher.php:53
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor\process
‪array process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
Definition: SiteProcessor.php:47