diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
index d666410..2c0833e 100644
--- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
+++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php
@@ -71,6 +71,7 @@ class PagesIndexer extends TcaIndexer
}
}
+ $record['media'] = $this->fetchMediaForPage($record['uid']);
$content = $this->fetchContentForPage($record['uid']);
if ($content !== []) {
$record['content'] = $content['content'];
@@ -136,4 +137,24 @@ class PagesIndexer extends TcaIndexer
return $imageRelationUids;
}
+
+ /**
+ * @param int $uid
+ * @return []
+ */
+ protected function fetchMediaForPage($uid)
+ {
+ $imageRelationUids = [];
+ $imageRelations = $this->fileRepository->findByRelation(
+ 'pages',
+ 'media',
+ $uid
+ );
+
+ foreach ($imageRelations as $relation) {
+ $imageRelationUids[] = $relation->getUid();
+ }
+
+ return $imageRelationUids;
+ }
}
diff --git a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
index 02e6ca3..4267d79 100644
--- a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
+++ b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php
@@ -205,4 +205,33 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase
'Record was indexed with resolved category relation, but should not have any.'
);
}
+
+ /**
+ * @test
+ */
+ public function indexPagesMedia()
+ {
+ \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class)
+ ->get(IndexerFactory::class)
+ ->getIndexer('pages')
+ ->indexAllDocuments()
+ ;
+
+ $response = $this->client->request('typo3content/_search?q=*:*');
+
+ $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.');
+ $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.');
+ $this->assertArraySubset(
+ [
+ '_source' => [
+ 'media' => [
+ 10, 1
+ ]
+ ]
+ ],
+ $response->getData()['hits']['hits'][0],
+ false,
+ 'Record was not indexed.'
+ );
+ }
}
diff --git a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
index 3692135..aa2a8fa 100644
--- a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
+++ b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml
@@ -99,4 +99,71 @@
0
0
+
+
+ 2
+ 1
+ Example page with
+ Used as abstract as no abstract is defined.
+ 2
+
+
+
+ 1
+ 1
+ 1
+ 2
+ pages
+ media
+ 2
+ sys_file
+
+
+
+
+
+ 10
+ 1
+ 2
+ 2
+ pages
+ media
+ 1
+ sys_file
+
+
+
+
+
+ 1
+ 0
+ 1
+ 2
+ full/file/path.png
+ 94dd1f9645114cf1344438ac7188db972768f59f
+ 67887283a03f465f1004d1d43a157ee1f1c59be5
+ png
+ image/png
+ path2.png
+ c1dd34eb34d651ee6ca6ac52dea595db75d8e9d2
+ 3044
+ 1432306303
+ 1432306303
+
+
+ 2
+ 0
+ 1
+ 2
+ full/file/path2.png
+ 94dd1f9645114cf1344438ac7188db972768f59f
+ 67887283a03f465f1004d1d43a157ee1f1c59be5
+ png
+ image/png
+ path2.png
+ c1dd34eb34d651ee6ca6ac52dea595db75d8e9d2
+ 3044
+ 1432306303
+ 1432306303
+