/** * Calculates image width, height and type from the image resource * The getimagesize() method may either return FALSE; or throw a Warning * which is translated to a \TYPO3\Flow\Error\Exception by Flow. In both * cases \TYPO3\Media\Exception\ImageFileException should be thrown. * * @throws \TYPO3\Media\Exception\ImageFileException * @return void */ protected function initialize() { try { $imageSize = getimagesize('resource://' . $this->originalResource->getResourcePointer()->getHash()); if ($imageSize === FALSE) { throw new \TYPO3\Flow\Exception('The given resource was not a valid image file', 1336662898); } $this->width = (int) $imageSize[0]; $this->height = (int) $imageSize[1]; $this->type = (int) $imageSize[2]; } catch (\TYPO3\Flow\Exception $exception) { throw $exception; } catch (\TYPO3\Flow\Exception $exception) { $exceptionMessage = 'An error with code "' . $exception->getCode() . '" occured when trying to read the image: "' . $exception->getMessage() . '"'; throw new \TYPO3\Flow\Exception($exceptionMessage, 1336663970); } }
/** * Returns the publish path and filename to be used to publish the specified persistent resource * * @param \TYPO3\Flow\Resource\Resource $resource The resource to build the publish path and filename for * @param boolean $returnFilename FALSE if only the directory without the filename should be returned * @return string The publish path and filename */ protected function buildPersistentResourcePublishPathAndFilename(\TYPO3\Flow\Resource\Resource $resource, $returnFilename) { $publishPath = $this->resourcesPublishingPath . 'Persistent/'; if ($returnFilename === TRUE) { return $publishPath . $resource->getResourcePointer()->getHash() . '.' . $resource->getFileExtension(); } return $publishPath; }
/** * {@inheritDoc} */ public function getResourcePointer() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getResourcePointer', array()); return parent::getResourcePointer(); }
/** * @param \TYPO3\Flow\Resource\Resource $photo * return void */ public function setPhoto(\TYPO3\Flow\Resource\Resource $photo = null) { if ($photo && $this->photo && $photo->getResourcePointer() == $this->photo->getResourcePointer()) { return; } $this->photo = $photo; }
/** * Returns the private path to the source of the given resource. * * @param \TYPO3\Flow\Resource\Resource $resource * @return mixed The full path and filename to the source of the given resource or FALSE if the resource file doesn't exist */ protected function getPersistentResourceSourcePathAndFilename(\TYPO3\Flow\Resource\Resource $resource) { $pathAndFilename = FLOW_PATH_DATA . 'Persistent/Resources/' . $resource->getResourcePointer()->getHash(); return file_exists($pathAndFilename) ? $pathAndFilename : FALSE; }