- press-release-images-manager-v2 hinter IMAGE_RIGHTS_V2: drei Blöcke, Vorbelegung aus Metadaten, Bestätigung mit archiviertem Wortlaut, Bild-Bindung über Hash, Fokuspunkt und Letterbox, Zustände absent/prefilled/error - CustomerImageConfirmation: Magic-Link an den Kontoinhaber, Karte auf der Kundenseite, Kanal magic_link - PressReleaseImageRemover: nie veröffentlicht = alles sofort weg, veröffentlicht = Soft Delete, Original bleibt - ConversionSource::MailImageConfirmation Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\PressRelease\Images;
|
|
|
|
use App\Models\PressReleaseImage;
|
|
use App\Services\Image\ImageService;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
/**
|
|
* Entfernt ein Titelbild (Bildkennzeichnung E.3, Decision-Update E4):
|
|
*
|
|
* - nie veröffentlicht: Derivate, Original, Snapshot und Bestätigung sofort
|
|
* und vollständig weg, die Zeile wird hart gelöscht;
|
|
* - veröffentlicht: Derivate weg, Zeile weich gelöscht; Original, Snapshot
|
|
* und Bestätigung bleiben für das Beweisarchiv (Block F übernimmt die
|
|
* Überführung und die Frist).
|
|
*
|
|
* Bestand ohne `rules_version` hat weder Original noch Protokoll und wird
|
|
* wie bisher behandelt (Derivate weg, Soft Delete).
|
|
*/
|
|
class PressReleaseImageRemover
|
|
{
|
|
public function __construct(private readonly ImageService $imageService) {}
|
|
|
|
public function remove(PressReleaseImage $image): void
|
|
{
|
|
$this->imageService->deletePressReleaseImage($image->disk, $image->path, $image->variants);
|
|
|
|
if ($image->wasEverPublished() || $image->isLegacyRules()) {
|
|
$image->delete();
|
|
|
|
return;
|
|
}
|
|
|
|
DB::transaction(function () use ($image): void {
|
|
foreach ($image->rightsConfirmations()->get() as $confirmation) {
|
|
$confirmation->purgeForUnpublished();
|
|
}
|
|
|
|
if ($image->original_path !== null) {
|
|
Storage::disk($image->original_disk ?? (string) config('images.originals_disk'))->delete($image->original_path);
|
|
}
|
|
|
|
if ($image->published_snapshot_path !== null) {
|
|
Storage::disk($image->original_disk ?? (string) config('images.originals_disk'))->delete($image->published_snapshot_path);
|
|
}
|
|
|
|
$image->forceDelete();
|
|
});
|
|
}
|
|
}
|