Fix: No variants for sound and videos - yet
This commit is contained in:
parent
604eee1ba7
commit
c406ec8469
|
@ -6,6 +6,7 @@
|
|||
use App\Classes\Traits\Repairs\RepairsImages;
|
||||
use App\Classes\Traits\Repairs\RepairsSounds;
|
||||
use App\Classes\Traits\Repairs\RepairsVideos;
|
||||
use App\Exceptions\AttachmentNotFound;
|
||||
use App\View\Components\Image;
|
||||
use App\View\Components\Sound;
|
||||
use App\View\Components\Video;
|
||||
|
@ -158,8 +159,8 @@ public function replaceAttachmentsInMarkdown(string $markdown)
|
|||
|
||||
foreach ($matches[1] as $index => $ref) {
|
||||
try {
|
||||
$component = $this->getComponentByRef($ref);
|
||||
} catch (Exception $ex) {
|
||||
$component = $this->getComponentByRef($ref, 'article');
|
||||
} catch (AttachmentNotFound $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -179,17 +180,15 @@ public function getComponentByRef(string $ref, ?string $filter = null)
|
|||
$variant = null;
|
||||
|
||||
if (!empty($filter)) {
|
||||
$variant = $this->getVariantData($ref, $filter);
|
||||
$variant = $this->getVariantData($ref, $filter) ?? null;
|
||||
}
|
||||
|
||||
// We set the fullname to the full path of the file in the filesystem
|
||||
// so the Blade component does not have to worry about it
|
||||
$attachment['filename'] = $this->getAttachmentFullPath($ref);
|
||||
|
||||
if (!empty($filter)) {
|
||||
if (!empty($filter) && !empty($variant)) {
|
||||
$variant['filename'] = $this->getVariantFullPath($ref, $filter);
|
||||
} else {
|
||||
$variant = $attachment;
|
||||
}
|
||||
|
||||
$component = $this->getBladeComponent($attachment, $variant);
|
||||
|
@ -288,7 +287,7 @@ public function getAttachmentData(string $ref): array
|
|||
$data = $this->manager->get(sprintf('files.%s', $ref));
|
||||
|
||||
if (empty($data)) {
|
||||
throw new Exception(sprintf('Unknown attachment %s', $ref));
|
||||
throw new AttachmentNotFound(sprintf('Unknown attachment %s', $ref));
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -350,9 +349,9 @@ private function getBladeComponent(array $data, ?array $variant = [])
|
|||
case self::Images:
|
||||
return new Image($data, $variant);
|
||||
case self::Sounds:
|
||||
return new Sound($data, $variant);
|
||||
return new Sound($data);
|
||||
case self::Videos:
|
||||
return new Video($data, $variant);
|
||||
return new Video($data);
|
||||
default:
|
||||
throw new Exception(sprintf('Unknown Blade Component for attachment kind "%s"', $this->kind));
|
||||
}
|
||||
|
|
10
app/Exceptions/AttachmentNotFound.php
Normal file
10
app/Exceptions/AttachmentNotFound.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AttachmentNotFound extends Exception
|
||||
{
|
||||
//
|
||||
}
|
Loading…
Reference in New Issue
Block a user