final class GenerateThumbnail implements IPsr14Event
{
private string $pathname;
+ private bool $sourceIsDamaged = false;
public function __construct(
public readonly File $file,
{
return $this->pathname ?? null;
}
+
+ /**
+ * Flags the source image as damaged which should stop further processing
+ * of this file.
+ */
+ public function markSourceAsDamaged(): void
+ {
+ $this->sourceIsDamaged = true;
+ }
+
+ public function sourceIsMarkedAsDamaged(): bool
+ {
+ return $this->sourceIsDamaged;
+ }
}
final class GenerateWebpVariant implements IPsr14Event
{
private string $pathname;
+ private bool $sourceIsDamaged = false;
public function __construct(
public readonly File $file
{
return $this->pathname ?? null;
}
+
+ /**
+ * Flags the source image as damaged which should stop further processing
+ * of this file.
+ */
+ public function markSourceAsDamaged(): void
+ {
+ $this->sourceIsDamaged = true;
+ }
+
+ public function sourceIsMarkedAsDamaged(): bool
+ {
+ return $this->sourceIsDamaged;
+ }
}
$event = new GenerateWebpVariant($file);
EventHandler::getInstance()->fire($event);
+ if ($event->sourceIsMarkedAsDamaged()) {
+ throw new DamagedImage($file->fileID);
+ }
$filename = $event->getPathname();
if ($filename === null) {
$event = new GenerateThumbnail($file, $format);
EventHandler::getInstance()->fire($event);
+ if ($event->sourceIsMarkedAsDamaged()) {
+ throw new DamagedImage($file->fileID);
+ }
$filename = $event->getPathname();
if ($filename === null) {