From 937d8b65c35a0d2f0f42aed6a1f97017a972583d Mon Sep 17 00:00:00 2001 From: roadiz-ci Date: Fri, 8 Mar 2024 14:45:30 +0000 Subject: [PATCH] Merge tag v2.2.12 into develop --- config/services.yaml | 2 -- src/Entity/Document.php | 5 ++++- src/Logger/DoctrineHandler.php | 2 +- src/Routing/DocumentUrlGenerator.php | 12 +----------- src/TwigExtension/DocumentUrlExtension.php | 4 ++-- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index c8a5f262..1e50e239 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -27,7 +27,6 @@ services: $cmsVersion: '%roadiz_core.cms_version%' $appVersion: '%roadiz_core.app_version%' $cmsVersionPrefix: '%roadiz_core.cms_version_prefix%' - $staticDomain: '%roadiz_core.static_domain_name%' $hideRoadizVersion: '%roadiz_core.hide_roadiz_version%' $inheritanceType: '%roadiz_core.inheritance_type%' $maxPixelSize: '%rz_intervention_request.max_pixel_size%' @@ -544,7 +543,6 @@ services: alias: RZ\Roadiz\CoreBundle\Filesystem\RoadizFileDirectories public: true - RZ\Roadiz\Documents\Packages: ~ RZ\Roadiz\Documents\DownscaleImageManager: ~ RZ\Roadiz\Documents\DocumentArchiver: ~ # diff --git a/src/Entity/Document.php b/src/Entity/Document.php index 0ee2b0ad..2f8db769 100644 --- a/src/Entity/Document.php +++ b/src/Entity/Document.php @@ -720,7 +720,10 @@ public function hasThumbnails(): bool */ public function getThumbnails(): Collection { - return $this->thumbnails; + // Filter private thumbnails + return $this->thumbnails->filter(function (DocumentInterface $thumbnail) { + return !$thumbnail->isPrivate(); + }); } public function setThumbnails(Collection $thumbnails): static diff --git a/src/Logger/DoctrineHandler.php b/src/Logger/DoctrineHandler.php index 399e05be..bcc9e42c 100644 --- a/src/Logger/DoctrineHandler.php +++ b/src/Logger/DoctrineHandler.php @@ -46,7 +46,7 @@ public function __construct( protected function getThumbnailSourcePath(?DocumentInterface $thumbnail): ?string { - if (null === $thumbnail) { + if (null === $thumbnail || $thumbnail->isPrivate()) { return null; } return $this->documentUrlGenerator diff --git a/src/Routing/DocumentUrlGenerator.php b/src/Routing/DocumentUrlGenerator.php index 78c17e6b..e329f2f8 100644 --- a/src/Routing/DocumentUrlGenerator.php +++ b/src/Routing/DocumentUrlGenerator.php @@ -13,23 +13,13 @@ final class DocumentUrlGenerator extends AbstractDocumentUrlGenerator { - private UrlGeneratorInterface $urlGenerator; - - /** - * @param FilesystemOperator $documentsStorage - * @param UrlHelper $urlHelper - * @param UrlGeneratorInterface $urlGenerator - * @param CacheItemPoolInterface $optionsCacheAdapter - * @throws InvalidArgumentException - */ public function __construct( FilesystemOperator $documentsStorage, UrlHelper $urlHelper, - UrlGeneratorInterface $urlGenerator, + private readonly UrlGeneratorInterface $urlGenerator, CacheItemPoolInterface $optionsCacheAdapter ) { parent::__construct($documentsStorage, $urlHelper, $optionsCacheAdapter); - $this->urlGenerator = $urlGenerator; } /** diff --git a/src/TwigExtension/DocumentUrlExtension.php b/src/TwigExtension/DocumentUrlExtension.php index f7c59709..af68dd7d 100644 --- a/src/TwigExtension/DocumentUrlExtension.php +++ b/src/TwigExtension/DocumentUrlExtension.php @@ -5,7 +5,7 @@ namespace RZ\Roadiz\CoreBundle\TwigExtension; use RZ\Roadiz\Core\AbstractEntities\PersistableInterface; -use RZ\Roadiz\CoreBundle\Entity\Document; +use RZ\Roadiz\Documents\Models\DocumentInterface; use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface; use Symfony\Component\OptionsResolver\Exception\InvalidArgumentException; use Twig\Error\RuntimeError; @@ -55,7 +55,7 @@ public function getUrl(PersistableInterface $mixed = null, array $criteria = []) } } - if ($mixed instanceof Document) { + if ($mixed instanceof DocumentInterface) { try { $absolute = false; if (isset($criteria['absolute'])) {