Explorar o código

resolve conflicts

Olivier Massot hai 1 ano
pai
achega
26ec68a206

+ 4 - 0
.env

@@ -31,6 +31,10 @@ MERCURE_JWT_SECRET=xxx
 CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)$
 ###< nelmio/cors-bundle ###
 
+###> url v2 ###
+PUBLIC_API_BASE_URL=https://local.ap2i.opentalent.fr
+###
+
 ###> lexik/jwt-authentication-bundle ###
 JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
 JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem

BIN=BIN
public/images/missing-file.png


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

@@ -90,14 +90,21 @@ class LocalStorage implements FileStorageInterface
     }
 
     /**
-     * Retoune l'URL de l'image, à la bonne taille, contenu dans la File.
+     * Retourne l'URL de l'image, à la bonne taille, contenu dans le File.
      */
     public function getImageUrl(File $file, string $size, bool $relativePath): string
     {
         $filterName = $this->getFilterFromSizeAndConfig($size, !empty($file->getConfig()));
         $path = $file->getPath();
+
         if (!$this->cacheManager->isStored($path, $filterName)) {
-            $this->imageFactory->createImageContent($file, $filterName);
+            try {
+                $this->imageFactory->createImageContent($file, $filterName);
+            } catch (\Exception $e) {
+                $path = 'images/missing-file.png';
+
+                return $relativePath ? $path : $this->urlBuilder->getAbsoluteUrl($path);
+            }
         }
         $url = $this->cacheManager->resolve($path, $filterName);
 

+ 3 - 3
src/Service/Utils/UrlBuilder.php

@@ -25,7 +25,7 @@ class UrlBuilder
     {
         $url = $base;
         foreach ($tails as $tail) {
-            $url = rtrim($url, '/').'/'.ltrim(strval($tail), '/');
+            $url = trim($url, '/').'/'.trim(strval($tail), '/');
         }
 
         return $url;
@@ -81,7 +81,7 @@ class UrlBuilder
      * @param list<string>  $parameters    A list of parameters (can be an empty array)
      * @param bool          $preprendHttps Should the 'https://' be prepended if missing
      */
-    public static function concat(string $url, array $tails, array $parameters, bool $preprendHttps = false): string
+    public static function concat(string $url, array $tails, array $parameters = [], bool $preprendHttps = false): string
     {
         $url = self::concatParameters(self::concatPath($url, $tails), $parameters);
         if ($preprendHttps) {
@@ -104,6 +104,6 @@ class UrlBuilder
      */
     public function getAbsoluteUrl(string $path): string
     {
-        return self::concat($this->baseUrl, [$path], []);
+        return self::concat($this->baseUrl, [$path]);
     }
 }