Skip to content

Commit a75d237

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
1 parent 1a7d1ff commit a75d237

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\Routing\PageArguments;
3031
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
3132
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -67,10 +68,12 @@ public function fromPage(
6768

6869
$document->setField('id', $documentId);
6970
$document->setField('site', $site->getSiteIdentifier());
71+
$document->setField('typo3Context_stringS', (string)Environment::getContext());
7072
if ($this->extensionConfiguration->getSiteHashStrategy() === 0) {
7173
$document->setField('site', $site->getDomain());
7274
}
7375
$document->setField('siteHash', $site->getSiteHash());
76+
$document->setField('domain_stringS', $site->getDomain());
7477
$document->setField('appKey', 'EXT:solr');
7578
$document->setField('type', 'pages');
7679

@@ -131,10 +134,12 @@ public function fromRecord(array $itemRecord, string $type, int $rootPageUid, st
131134
$document->setField('appKey', 'EXT:solr');
132135

133136
$document->setField('site', $site->getSiteIdentifier());
137+
$document->setField('typo3Context_stringS', (string)Environment::getContext());
134138
if ($this->extensionConfiguration->getSiteHashStrategy() === 0) {
135139
$document->setField('site', $site->getDomain());
136140
}
137141
$document->setField('siteHash', $site->getSiteHash());
142+
$document->setField('domain_stringS', $site->getDomain());
138143

139144
// uid, pid
140145
$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
@@ -168,7 +168,7 @@ public function canBuildFromRecord(): void
168168
$this->fakeDocumentId('testSiteHash/news/4711');
169169

170170
$this->siteMock->expects(self::any())->method('getRootPageId')->willReturn(99);
171-
$this->siteMock->expects(self::once())->method('getDomain')->willReturn('test.typo3.org');
171+
$this->siteMock->expects(self::any())->method('getDomain')->willReturn('test.typo3.org');
172172
$this->siteMock->expects(self::any())->method('getSiteHash')->willReturn('testSiteHash');
173173
$this->variantIdBuilderMock->expects(self::once())->method('buildFromTypeAndUid')->with($type, 4711, $fakeRecord, $this->siteMock)->willReturn('testVariantId');
174174

0 commit comments

Comments
 (0)