From 63f8418e05163202fdff89bdc1615907d675fead Mon Sep 17 00:00:00 2001 From: nilov Date: Mon, 16 Apr 2018 19:46:03 +0700 Subject: [PATCH] Add absolute url parameter for MediaStructure::getStructure. --- Util/MediaStructure.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Util/MediaStructure.php b/Util/MediaStructure.php index ac49494..bcfa358 100644 --- a/Util/MediaStructure.php +++ b/Util/MediaStructure.php @@ -54,15 +54,16 @@ public function setImagineHelper($imagineHelper) } /** - * @param array $medias + * @param array $medias * @param string $thumbnailFilter - * @param bool $securedId + * @param bool $securedId + * @param bool $isAbsolute * @return array */ - public function getStructure(array $medias, $thumbnailFilter = null, $securedId = false) + public function getStructure(array $medias, $thumbnailFilter = null, $securedId = false, $isAbsolute = false) { - $structure = array_map(function (Media $media) use ($thumbnailFilter, $securedId) { - return $this->getMediaStructure($media, $thumbnailFilter, $securedId); + $structure = array_map(function (Media $media) use ($thumbnailFilter, $securedId, $isAbsolute) { + return $this->getMediaStructure($media, $thumbnailFilter, $securedId, $isAbsolute); }, $medias); return $structure; @@ -70,22 +71,26 @@ public function getStructure(array $medias, $thumbnailFilter = null, $securedId /** * @param MediaInterface $media - * @param string $thumbnailFilter - * @param bool $securedId + * @param string $thumbnailFilter + * @param bool $securedId + * @param bool $isAbsolute * @return array * @throws Exception */ - public function getMediaStructure(MediaInterface $media, $thumbnailFilter = null, $securedId = false) + public function getMediaStructure(MediaInterface $media, $thumbnailFilter = null, $securedId = false, $isAbsolute = false) { - $thumbnailPath = $this->mediaHelper->getThumbnailPath($media); - $contentPath = $this->mediaHelper->getContentPath($media); + $contentPath = $this->mediaHelper->getContentPath($media, $isAbsolute); if ($thumbnailFilter) { if (!$this->imagineHelper instanceof ImagineHelper) { throw new Exception('ImagineHelper is not defined. You need use Liip\ImagineBundle.'); } + $thumbnailPath = $this->mediaHelper->getThumbnailPath($media, false); $thumbnailPath = $this->imagineHelper->filter($thumbnailPath, $thumbnailFilter); + + } else { + $thumbnailPath = $this->mediaHelper->getThumbnailPath($media, $isAbsolute); } return [