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\RepairsImages;
|
||||||
use App\Classes\Traits\Repairs\RepairsSounds;
|
use App\Classes\Traits\Repairs\RepairsSounds;
|
||||||
use App\Classes\Traits\Repairs\RepairsVideos;
|
use App\Classes\Traits\Repairs\RepairsVideos;
|
||||||
|
use App\Exceptions\AttachmentNotFound;
|
||||||
use App\View\Components\Image;
|
use App\View\Components\Image;
|
||||||
use App\View\Components\Sound;
|
use App\View\Components\Sound;
|
||||||
use App\View\Components\Video;
|
use App\View\Components\Video;
|
||||||
|
@ -158,8 +159,8 @@ public function replaceAttachmentsInMarkdown(string $markdown)
|
||||||
|
|
||||||
foreach ($matches[1] as $index => $ref) {
|
foreach ($matches[1] as $index => $ref) {
|
||||||
try {
|
try {
|
||||||
$component = $this->getComponentByRef($ref);
|
$component = $this->getComponentByRef($ref, 'article');
|
||||||
} catch (Exception $ex) {
|
} catch (AttachmentNotFound $ex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,17 +180,15 @@ public function getComponentByRef(string $ref, ?string $filter = null)
|
||||||
$variant = null;
|
$variant = null;
|
||||||
|
|
||||||
if (!empty($filter)) {
|
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
|
// 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
|
// so the Blade component does not have to worry about it
|
||||||
$attachment['filename'] = $this->getAttachmentFullPath($ref);
|
$attachment['filename'] = $this->getAttachmentFullPath($ref);
|
||||||
|
|
||||||
if (!empty($filter)) {
|
if (!empty($filter) && !empty($variant)) {
|
||||||
$variant['filename'] = $this->getVariantFullPath($ref, $filter);
|
$variant['filename'] = $this->getVariantFullPath($ref, $filter);
|
||||||
} else {
|
|
||||||
$variant = $attachment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$component = $this->getBladeComponent($attachment, $variant);
|
$component = $this->getBladeComponent($attachment, $variant);
|
||||||
|
@ -288,7 +287,7 @@ public function getAttachmentData(string $ref): array
|
||||||
$data = $this->manager->get(sprintf('files.%s', $ref));
|
$data = $this->manager->get(sprintf('files.%s', $ref));
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
throw new Exception(sprintf('Unknown attachment %s', $ref));
|
throw new AttachmentNotFound(sprintf('Unknown attachment %s', $ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -350,9 +349,9 @@ private function getBladeComponent(array $data, ?array $variant = [])
|
||||||
case self::Images:
|
case self::Images:
|
||||||
return new Image($data, $variant);
|
return new Image($data, $variant);
|
||||||
case self::Sounds:
|
case self::Sounds:
|
||||||
return new Sound($data, $variant);
|
return new Sound($data);
|
||||||
case self::Videos:
|
case self::Videos:
|
||||||
return new Video($data, $variant);
|
return new Video($data);
|
||||||
default:
|
default:
|
||||||
throw new Exception(sprintf('Unknown Blade Component for attachment kind "%s"', $this->kind));
|
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