Created
September 4, 2018 08:29
-
-
Save ogrosko/750cb5a2b01a1af75b39d94ccc687308 to your computer and use it in GitHub Desktop.
Typo3 localization FAL workarround fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> | |
*/ | |
public function getMedia(): \TYPO3\CMS\Extbase\Persistence\ObjectStorage | |
{ | |
//Never ending typo3 BUG with typo3 FAL localizations | |
if ($GLOBALS['TSFE']->sys_language_uid > 0) { | |
$query = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference'); | |
$fileReferences = $query | |
->select('uid') | |
->from('sys_file_reference') | |
->where( | |
$query->expr()->eq('pid', $query->createNamedParameter($this->getUid(), \PDO::PARAM_INT)), | |
$query->expr()->eq('tablenames', $query->createNamedParameter('pages_language_overlay')), | |
$query->expr()->eq('sys_language_uid', $query->createNamedParameter($GLOBALS['TSFE']->sys_language_uid, \PDO::PARAM_INT)), | |
$query->expr()->eq('fieldname', $query->createNamedParameter('media')) | |
) | |
->orderBy('sorting_foreign', 'DESC') | |
->execute(); | |
if ($fileReferences->rowCount() > 0) { | |
$fileFactory = ResourceFactory::getInstance(); | |
$media = new ObjectStorage(); | |
while ($row = $fileReferences->fetch()) { | |
$media->attach($fileFactory->getFileReferenceObject($row['uid'])); | |
} | |
return $media; | |
} | |
} | |
return $this->media; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment