浏览代码

fix image management

Olivier Massot 6 月之前
父节点
当前提交
0ef631b02f
共有 3 个文件被更改,包括 7 次插入6 次删除
  1. 4 4
      src/Entity/Core/File.php
  2. 1 1
      src/Service/File/Factory/ImageFactory.php
  3. 2 1
      src/Service/File/Storage/LocalStorage.php

+ 4 - 4
src/Entity/Core/File.php

@@ -75,14 +75,14 @@ class File
     /**
     /**
      * Slug du fichier (i.e. le chemin d'accès relatif).
      * Slug du fichier (i.e. le chemin d'accès relatif).
      */
      */
-    #[ORM\Column(length: 255)]
-    private string $slug;
+    #[ORM\Column(length: 255, nullable: true)]
+    private ?string $slug;
 
 
     /**
     /**
      * Chemin d'accès du fichier.
      * Chemin d'accès du fichier.
      */
      */
-    #[ORM\Column(length: 255)]
-    private string $path;
+    #[ORM\Column(length: 255, nullable: true)]
+    private ?string $path;
 
 
     /**
     /**
      * Nom du fichier.
      * Nom du fichier.

+ 1 - 1
src/Service/File/Factory/ImageFactory.php

@@ -30,7 +30,7 @@ class ImageFactory
     public function createImageContent(File $file, string $filterName): void
     public function createImageContent(File $file, string $filterName): void
     {
     {
         $filters_options = $this->getCropFilterOptions($file->getConfig());
         $filters_options = $this->getCropFilterOptions($file->getConfig());
-        $path = $file->getPath();
+        $path = $file->getSlug();
         $this->createAndStore($path, $filterName, $filters_options);
         $this->createAndStore($path, $filterName, $filters_options);
     }
     }
 
 

+ 2 - 1
src/Service/File/Storage/LocalStorage.php

@@ -96,7 +96,7 @@ class LocalStorage implements FileStorageInterface
     public function getImageUrl(File $file, string $size, bool $relativePath): string
     public function getImageUrl(File $file, string $size, bool $relativePath): string
     {
     {
         $filterName = $this->getFilterFromSizeAndConfig($size, !empty($file->getConfig()));
         $filterName = $this->getFilterFromSizeAndConfig($size, !empty($file->getConfig()));
-        $path = $file->getPath();
+        $path = $file->getSlug();
 
 
         if (!$this->cacheManager->isStored($path, $filterName)) {
         if (!$this->cacheManager->isStored($path, $filterName)) {
             try {
             try {
@@ -159,6 +159,7 @@ class LocalStorage implements FileStorageInterface
 
 
         $file = (new File())
         $file = (new File())
             ->setName($filename)
             ->setName($filename)
+            ->setSlug(null)
             ->setOrganization($organization)
             ->setOrganization($organization)
             ->setPerson($person)
             ->setPerson($person)
             ->setType($type)
             ->setType($type)