-
-
Save grimmcreative/ef1e00fb7f3242f5196695ae94e8a27f to your computer and use it in GitHub Desktop.
Revisions
-
sascha-seyfert revised this gist
Jul 29, 2016 . 1 changed file with 45 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,50 @@ <?php use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; class Page extends AbstractEntity { /** * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $myImage; /** * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference */ public function getMyImage() { $fileReference = $this->findFileReference('my_image'); if (is_null($fileReference)) { return null; } $this->setMyImage($fileReference); if ($this->myImage instanceof LazyLoadingProxy) { $this->myImage->_loadRealInstance(); } return $this->myImage->getOriginalResource(); } /** * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $myImage * @return void */ public function setMyImage(FileReference $myImage) { $this->myImage = $myImage; } /** * @param string $column * @return null|FileReference */ private function findFileReference($column = 'my_image') { $this->pageHandler->sys_language_uid = $GLOBALS['TSFE']->sys_language_uid; @@ -34,4 +76,5 @@ private function findFileReference($column = 'image') $fileReference->setOriginalResource($fileResource); return $fileReference; } } -
sascha-seyfert created this gist
Jul 29, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ /** * @param string $column * @return null|FileReference */ private function findFileReference($column = 'image') { $this->pageHandler->sys_language_uid = $GLOBALS['TSFE']->sys_language_uid; /** @var array $pageRecord */ $pageRecord = $this->pageHandler->getPage($this->getUid()); $uid = $this->getUid(); $table = 'pages'; if ($this->isPageRecordTranslatable($pageRecord)) { $uid = (int)$pageRecord['_PAGES_OVERLAY_UID']; $table = 'pages_language_overlay'; } $fileObject = $this->fileRepository->findByRelation( $table, $column, $uid ); if (!is_array($fileObject) || count($fileObject) === 0) { return null; } /** @var \TYPO3\CMS\Core\Resource\FileReference $fileResource */ $fileResource = $fileObject[0]; $fileReference = new FileReference(); $fileReference->setOriginalResource($fileResource); return $fileReference; }