1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use ApacheSolrForTypo3\Solr\FrontendEnvironment\Tsfe; |
6
|
|
|
use ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript; |
7
|
|
|
use TYPO3\CMS\Core\Exception\SiteNotFoundException; |
8
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
9
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class FrontendEnvironment implements SingletonInterface |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var TypoScript |
17
|
|
|
*/ |
18
|
|
|
private $typoScript = null; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Tsfe |
22
|
|
|
*/ |
23
|
|
|
private $tsfe = null; |
24
|
|
|
|
25
|
|
|
public function __construct(Tsfe $tsfe = null, TypoScript $typoScript = null) |
26
|
|
|
{ |
27
|
|
|
$this->tsfe = $tsfe ?? GeneralUtility::makeInstance(Tsfe::class); |
28
|
|
|
$this->typoScript = $typoScript ?? GeneralUtility::makeInstance(TypoScript::class); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function changeLanguageContext(int $pageId, int $language): void |
32
|
|
|
{ |
33
|
|
|
$this->tsfe->changeLanguageContext($pageId, $language); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Initializes the TSFE for a given page ID and language. |
38
|
|
|
* |
39
|
|
|
* @param $pageId |
40
|
|
|
* @param int $language |
41
|
|
|
* @throws SiteNotFoundException |
42
|
|
|
* @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException |
43
|
|
|
* @throws \TYPO3\CMS\Core\Http\ImmediateResponseException |
44
|
|
|
*/ |
45
|
|
|
public function initializeTsfe($pageId, $language = 0) |
46
|
|
|
{ |
47
|
|
|
$this->tsfe->initializeTsfe($pageId, $language); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getConfigurationFromPageId($pageId, $path, $language = 0) |
51
|
|
|
{ |
52
|
|
|
return $this->typoScript->getConfigurationFromPageId($pageId, $path, $language); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function isAllowedPageType(array $pageRecord, $configurationName = 'pages'): bool |
56
|
|
|
{ |
57
|
|
|
$configuration = $this->getConfigurationFromPageId($pageRecord['uid'], ''); |
58
|
|
|
$allowedPageTypes = $configuration->getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName); |
59
|
|
|
return in_array($pageRecord['doktype'], $allowedPageTypes); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getSolrConfigurationFromPageId($pageId, $language = 0) |
63
|
|
|
{ |
64
|
|
|
return $this->getConfigurationFromPageId($pageId, '', $language); |
65
|
|
|
} |
66
|
|
|
} |