From ddf38fad12523d10a457525b78c80cca68f3dcc8 Mon Sep 17 00:00:00 2001 From: Tomas Hermanek Date: Mon, 4 Nov 2024 09:45:19 +0100 Subject: [PATCH] Crop cache updates. --- src/Domain/Image/Crop/CropCache.php | 7 +++---- src/Event/Subscriber/AssetFileDeleteEventSubscriber.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Domain/Image/Crop/CropCache.php b/src/Domain/Image/Crop/CropCache.php index 8e726154..269a5054 100644 --- a/src/Domain/Image/Crop/CropCache.php +++ b/src/Domain/Image/Crop/CropCache.php @@ -4,7 +4,6 @@ namespace AnzuSystems\CoreDamBundle\Domain\Image\Crop; -use AnzuSystems\CoreDamBundle\Entity\ExtSystem; use AnzuSystems\CoreDamBundle\Entity\ImageFile; use AnzuSystems\CoreDamBundle\FileSystem\FileSystemProvider; use AnzuSystems\CoreDamBundle\FileSystem\NameGenerator\NameGenerator; @@ -60,7 +59,7 @@ public function get(ImageFile $image, ImageCropDto $imageCrop): string public function removeCache(ImageFile $image): void { $this->removeCacheByOriginFilePath( - $image->getExtSystem(), + $image->getExtSystem()->getSlug(), $image->getAssetAttributes()->getFilePath() ); } @@ -68,10 +67,10 @@ public function removeCache(ImageFile $image): void /** * @throws FilesystemException */ - public function removeCacheByOriginFilePath(ExtSystem $extSystem, string $path): void + public function removeCacheByOriginFilePath(string $extSystemSlug, string $path): void { $this->fileSystemProvider - ->getCropFilesystemByExtSystemSlug($extSystem->getSlug()) + ->getCropFilesystemByExtSystemSlug($extSystemSlug) ->deleteDirectory( $this->getCacheDir($path) ); diff --git a/src/Event/Subscriber/AssetFileDeleteEventSubscriber.php b/src/Event/Subscriber/AssetFileDeleteEventSubscriber.php index 64c9360c..c741e0c9 100644 --- a/src/Event/Subscriber/AssetFileDeleteEventSubscriber.php +++ b/src/Event/Subscriber/AssetFileDeleteEventSubscriber.php @@ -36,7 +36,7 @@ public function deleteAssetFile(AssetFileDeleteEvent $event): void if ($event->getType()->is(AssetType::Image)) { if (false === empty($event->getAssetFile()->getFilePath())) { $this->cropCache->removeCacheByOriginFilePath( - $event->getAssetFile()->getExtSystem(), + $event->getAssetFile()->getExtSystem()->getSlug(), $event->getAssetFile()->getFilePath() ); }