mein-sterntours/app/Exceptions/Offer/OfferNotEditableException.php

31 lines
927 B
PHP

<?php
namespace App\Exceptions\Offer;
use App\Models\OfferVersion;
use DomainException;
/**
* Geworfen, wenn eine nicht-Draft-Version verändert werden soll.
* Klar abgrenzbarer Typ zu {@see InvalidOfferStatusException}
* (dort: Offer.status passt nicht; hier: OfferVersion.status blockiert Edits).
*/
class OfferNotEditableException extends DomainException
{
public readonly int $versionId;
public readonly string $currentStatus;
public function __construct(OfferVersion $v, string $attemptedAction = 'ändern')
{
$this->versionId = $v->id;
$this->currentStatus = $v->status;
parent::__construct(sprintf(
'OfferVersion #%d ist nicht mehr editierbar (status=%s). '
. 'Aktion „%s" erfordert eine Draft-Version — nutze createNewVersion() / supersede().',
$v->id,
$v->status,
$attemptedAction
));
}
}