/** * Get the item file resolution object * * @param Tx_Yag_Domain_Model_Item $item * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return Tx_Yag_Domain_Model_ResolutionFileCache */ public function getResolutionByItem(Tx_Yag_Domain_Model_Item $item, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $query = $this->createQuery(); $constraints = array(); $constraints[] = $query->equals('item', $item->getUid()); $constraints[] = $query->equals('paramhash', $resolutionConfiguration->getParameterHash()); $result = $query->matching($query->logicalAnd($constraints))->execute(); $object = NULL; if ($result !== NULL && !is_array($result) && $result->current() !== FALSE) { $object = $result->current(); $this->identityMap->registerObject($object, $object->getUid()); } return $object; }
/** * Get the item file resolution object * * @param Tx_Yag_Domain_Model_Item $item * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return Tx_Yag_Domain_Model_ResolutionFileCache */ public function getResolutionByItem(Tx_Yag_Domain_Model_Item $item, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $query = $this->createQuery(); $constraints = array(); $constraints[] = $query->equals('item', $item->getUid()); $constraints[] = $query->equals('paramhash', $resolutionConfiguration->getParameterHash()); $result = $query->matching($query->logicalAnd($constraints))->execute(); $object = null; if ($result !== null && !is_array($result) && $result->current() !== false) { $object = $result->current(); $session = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session'); $session->registerObject($object, $object->getUid()); } return $object; }
/** * (non-PHPdoc) * @see Classes/Domain/ImageProcessing/Tx_Yag_Domain_ImageProcessing_ProcessorInterface::generateResolution() */ public function generateResolution(Tx_Yag_Domain_Model_Item $origFile, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $resolutionFile = new Tx_Yag_Domain_Model_ResolutionFileCache($origFile, '', 0, 0, $resolutionConfiguration->getParameterHash()); $this->processFile($resolutionConfiguration, $origFile, $resolutionFile); $this->resolutionFileCacheRepository->add($resolutionFile); return $resolutionFile; }
/** * Wrapper for cObj->getImageResource in FE and BE * * @param Tx_Yag_Domain_Model_Item $origFile The original image * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return TYPO3\CMS\Core\Resource\ProcessedFile */ protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings()); $contentObject = $this->configurationManager->getContentObject(); /** @var $contentObject \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ if ($resolutionConfiguration->getMode() == 'GIFBUILDER') { $gifBuilderData = ['yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageHref' => $origFile->getHref(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName()]; $contentObject->start($gifBuilderData); $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings); } else { $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($sourcePathAndFileName); $imageResource = $contentObject->getImgResource($fileObject, $typoScriptSettings); } // $this->typo3CleanUp($imageResource); return $imageResource['processedFile']; }
/** * Retrieve a resolution file from local cache * * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @param Tx_Yag_Domain_Model_Item $item * @return Tx_Yag_Domain_Model_ResolutionFileCache|null */ protected function getResolutionFileFromLocalCache(Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration, Tx_Yag_Domain_Model_Item $item) { $objectIdentifier = md5($resolutionConfiguration->getParameterHash() . $item->getSourceuri()); if (array_key_exists($objectIdentifier, $this->localResolutionFileCache)) { return $this->localResolutionFileCache[$objectIdentifier]; } return NULL; }
/** * Wrapper for cObj->getImageResource in FE and BE * * @param Tx_Yag_Domain_Model_Item $origFile The original image * @param string $sourcePathAndFileName Must be used to access the file, as it may be overwritten if the original file was not found * @param Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration * @return array $imageData */ protected function getImageResource(Tx_Yag_Domain_Model_Item $origFile, $sourcePathAndFileName, Tx_Yag_Domain_Configuration_Image_ResolutionConfig $resolutionConfiguration) { $typoScriptSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($resolutionConfiguration->getSettings()); $contentObject = $this->configurationManager->getContentObject(); /** @var $contentObject tslib_cObj */ if ($resolutionConfiguration->getMode() == 'GIFBUILDER') { $gifBuilderData = array('yagImage' => $sourcePathAndFileName, 'yagImageTitle' => $origFile->getTitle(), 'yagImageUid' => $origFile->getUid(), 'yagAlbumUid' => $origFile->getAlbum()->getUid(), 'yagAlbumTitle' => $origFile->getAlbum()->getName(), 'yagGalleryUid' => $origFile->getAlbum()->getGallery()->getUid(), 'yagGalleryTitle' => $origFile->getAlbum()->getGallery()->getName()); $contentObject->start($gifBuilderData); $imageResource = $contentObject->getImgResource('GIFBUILDER', $typoScriptSettings); } else { $imageResource = $contentObject->getImgResource($sourcePathAndFileName, $typoScriptSettings); } $this->typo3CleanUp($imageResource, $sourcePathAndFileName); return $imageResource; }