Rich-Model Mahlzeit (MahlzeitStatus, Wochentag) mit Invarianten und Zustandsübergängen; DTOs + MahlzeitFactory (reine Mapping-Funktionen); Manager (create hängt an Ende an: maxSortOrder+1, find → 404) und Create/Update/Delete-UseCases mit Transaktion + Events nach Commit. Data-Layer: MahlzeitEntity (Tabelle essens_mahlzeiten, wochentage als CSV), Mapper (CSV/Enum/null), Provider (find/list/maxSortOrder), Processor (create/save/delete). DI-Bindings in services.yaml. ClockInterface (Logic) + SystemClock (Data). Tests: Model/Factory/UseCase-Unit + Provider/Processor/Mapper-Integration (In-Mem-SQLite). composer test grün (53 Tests, 161 Assertions).
24 lines
516 B
PHP
24 lines
516 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Logic\Essen\Dto;
|
|
|
|
use App\Logic\Essen\Model\Mahlzeit;
|
|
|
|
/**
|
|
* Response-DTO: Bearbeitung abgeschlossen. Trägt die ID + das aktualisierte Read-Modell.
|
|
*/
|
|
final class MahlzeitUpdateResponse
|
|
{
|
|
public function __construct(
|
|
public readonly int $id,
|
|
public readonly MahlzeitResponse $mahlzeit,
|
|
) {}
|
|
|
|
public static function fromModel(Mahlzeit $m): self
|
|
{
|
|
return new self(id: $m->id, mahlzeit: MahlzeitResponse::fromModel($m));
|
|
}
|
|
}
|