Skip to content

Commit d177bd6

Browse files
committed
[FEATURE] add typo3Context[_stringS] and domain[_stringS] fields to documents
This change * adds the fields to the documents, which will be renamed to native fields without `_stringS` in EXT:solr 13.1.x+: * `typo3Context_stringS` * `domain_stringS` * adds `typo3Context` as response data of ApiEid, to be able to set that field by external index writers Relates: #4411 Ports: #4413
1 parent 1855d14 commit d177bd6

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Classes/Domain/Search/ApacheSolrDocument/Builder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use ApacheSolrForTypo3\Solr\Typo3PageContentExtractor;
2727
use ApacheSolrForTypo3\Solr\Util;
2828
use Doctrine\DBAL\Exception as DBALException;
29+
use TYPO3\CMS\Core\Core\Environment;
2930
use TYPO3\CMS\Core\Utility\GeneralUtility;
3031
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
3132

@@ -61,10 +62,12 @@ public function fromPage(
6162

6263
$document->setField('id', $documentId);
6364
$document->setField('site', $site->getSiteIdentifier());
65+
$document->setField('typo3Context_stringS', (string)Environment::getContext());
6466
if ($this->extensionConfiguration->getSiteHashStrategy() === 0) {
6567
$document->setField('site', $site->getDomain());
6668
}
6769
$document->setField('siteHash', $site->getSiteHash());
70+
$document->setField('domain_stringS', $site->getDomain());
6871
$document->setField('appKey', 'EXT:solr');
6972
$document->setField('type', 'pages');
7073

@@ -125,10 +128,12 @@ public function fromRecord(array $itemRecord, string $type, int $rootPageUid, st
125128
$document->setField('appKey', 'EXT:solr');
126129

127130
$document->setField('site', $site->getSiteIdentifier());
131+
$document->setField('typo3Context_stringS', (string)Environment::getContext());
128132
if ($this->extensionConfiguration->getSiteHashStrategy() === 0) {
129133
$document->setField('site', $site->getDomain());
130134
}
131135
$document->setField('siteHash', $site->getSiteHash());
136+
$document->setField('domain_stringS', $site->getDomain());
132137

133138
// uid, pid
134139
$document->setField('uid', $itemRecord['uid']);

Classes/Eid/ApiEid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use ApacheSolrForTypo3\Solr\Domain\Site\SiteHashService;
2020
use Psr\Http\Message\ResponseInterface;
2121
use Psr\Http\Message\ServerRequestInterface;
22+
use TYPO3\CMS\Core\Core\Environment;
2223
use TYPO3\CMS\Core\Http\ImmediateResponseException;
2324
use TYPO3\CMS\Core\Http\JsonResponse;
2425
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -78,6 +79,7 @@ protected function getSiteHashResponse(ServerRequestInterface $request): JsonRes
7879
$siteHash = $siteHashService->getSiteHashForSiteIdentifier($siteIdentifier);
7980
$jsonResponseContents = [
8081
'sitehash' => $siteHash,
82+
'typo3Context' => (string)Environment::getContext(),
8183
];
8284
// @todo, remove this backwards-compatibility-adjustment together with siteHashStrategy setting.
8385
if (isset($queryParams['domain'])) {

Tests/Unit/Domain/Search/ApacheSolrDocument/BuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function canBuildFromRecord(): void
152152
$this->fakeDocumentId('testSiteHash/news/4711');
153153

154154
$this->siteMock->expects(self::any())->method('getRootPageId')->willReturn(99);
155-
$this->siteMock->expects(self::once())->method('getDomain')->willReturn('test.typo3.org');
155+
$this->siteMock->expects(self::any())->method('getDomain')->willReturn('test.typo3.org');
156156
$this->siteMock->expects(self::any())->method('getSiteHash')->willReturn('testSiteHash');
157157
$this->variantIdBuilderMock->expects(self::once())->method('buildFromTypeAndUid')->with($type, 4711, $fakeRecord, $this->siteMock)->willReturn('testVariantId');
158158

0 commit comments

Comments
 (0)