From: Vincent Vanwaelscappel Date: Fri, 11 Feb 2022 15:48:11 +0000 (+0100) Subject: wip #5089 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=77eb3abb56a5128403e142ff6146bd21da526d34;p=odl.git wip #5089 @0.25 --- diff --git a/app/Jobs/SearchIndex.php b/app/Jobs/SearchIndex.php index 64007dc..83f7caf 100644 --- a/app/Jobs/SearchIndex.php +++ b/app/Jobs/SearchIndex.php @@ -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/');