TASK: Refactor common code base

This commit is contained in:
Daniel Siepmann 2017-12-12 11:34:38 +01:00
parent 6423f510e2
commit a998f155c1
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -124,18 +124,7 @@ class PagesIndexer extends TcaIndexer
*/
protected function getContentElementImages($uidOfContentElement)
{
$imageRelationUids = [];
$imageRelations = $this->fileRepository->findByRelation(
'tt_content',
'image',
$uidOfContentElement
);
foreach ($imageRelations as $relation) {
$imageRelationUids[] = $relation->getUid();
}
return $imageRelationUids;
return $this->fetchSysFileReferenceUids($uidOfContentElement, 'tt_content', 'image');
}
/**
@ -143,13 +132,20 @@ class PagesIndexer extends TcaIndexer
* @return []
*/
protected function fetchMediaForPage($uid)
{
return $this->fetchSysFileReferenceUids($uid, 'pages', 'media');
}
/**
* @param int $uid
* @param string $tablename
* @param string $fieldname
* @return []
*/
protected function fetchSysFileReferenceUids($uid, $tablename, $fieldname)
{
$imageRelationUids = [];
$imageRelations = $this->fileRepository->findByRelation(
'pages',
'media',
$uid
);
$imageRelations = $this->fileRepository->findByRelation($tablename, $fieldname, $uid);
foreach ($imageRelations as $relation) {
$imageRelationUids[] = $relation->getUid();