]> _ Git - odl.git/commitdiff
wip #5089 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 11 Feb 2022 15:48:11 +0000 (16:48 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 11 Feb 2022 15:48:11 +0000 (16:48 +0100)
app/Jobs/SearchIndex.php

index 64007dc5e5e731cf8f3db1490c72f1ca263987b6..83f7caf8ce268b12226dc1a66cff274d7882bdb7 100644 (file)
@@ -77,7 +77,11 @@ class SearchIndex extends Index
         /** @var Asset[] $pdfs */
         $pdfs = Asset::getPDFInResources();
         foreach ($pdfs as $pdf) {
-            $document = new PDF($pdf->getFirstMediaInField('file_upload')->getPath());
+            $file = $pdf->getFirstMediaInField('file_upload');
+            if ($file == null) {
+                throw new \Exception('Aucun fichier dans l\'asset ' . $pdf->id);
+            }
+            $document = new PDF($file->getPath());
             $document->setId($pdf->id);
             $document->setUrl($this->relativeURL($pdf->getFirstMediaUrl($pdf->file_upload)));
             $document->setTitle($pdf->title);
@@ -88,7 +92,8 @@ class SearchIndex extends Index
         }
     }
 
-    public function relativeURL($URL) {
+    public function relativeURL($URL)
+    {
         // Get the relative URL by taking from /storage/ onwards
         // We assume that assets are always going to be in the storage folder
         return '.' . strstr($URL, '/storage/');