tsfe = $tsfe ?? GeneralUtility::makeInstance(Tsfe::class); $this->typoScript = $typoScript ?? GeneralUtility::makeInstance(TypoScript::class); } /** * Changes language context. * Should be used in indexing context. * * @param int $pageId * @param int $language */ public function changeLanguageContext(int $pageId, int $language): void { $this->tsfe->changeLanguageContext($pageId, $language); } /** * Initializes the TSFE for a given page ID and language. * * @param $pageId * @param int $language * @throws SiteNotFoundException * @throws ServiceUnavailableException * @throws ImmediateResponseException */ public function initializeTsfe($pageId, $language = 0) { $this->tsfe->initializeTsfe($pageId, $language); } /** * Loads the TypoScript configuration for a given page id and language. * Language usage may be disabled to get the default TypoScript * configuration. * * @param int $pageId * @param ?string $path * @param ?int $language * @return TypoScriptConfiguration */ public function getConfigurationFromPageId($pageId, $path = '', $language = 0): TypoScriptConfiguration { return $this->typoScript->getConfigurationFromPageId($pageId, $path, $language); } /** * Check whether the page record is within the configured allowed pages types(doktype) for indexing. * Uses TypoScript: plugin.tx_meilisearch.index.queue..allowedPageTypes * * @param array $pageRecord * @param ?string $configurationName * @return bool */ public function isAllowedPageType(array $pageRecord, $configurationName = 'pages'): bool { $configuration = $this->getConfigurationFromPageId($pageRecord['uid'], ''); $allowedPageTypes = $configuration->getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName); return in_array($pageRecord['doktype'], $allowedPageTypes); } /** * Returns TypoScriptConfiguration for desired page ID and language id. * * @param int $pageId * @param ?int $language * @return TypoScriptConfiguration */ public function getMeilisearchConfigurationFromPageId($pageId, $language = 0): TypoScriptConfiguration { return $this->getConfigurationFromPageId($pageId, '', $language); } }