Files
php-qml/framework/php/src/Maker/templates/ReadModelController.tpl.php
T

29 lines
769 B
PHP
Raw Normal View History

2026-05-03 20:28:50 +02:00
<?= "<?php\n" ?>
declare(strict_types=1);
namespace App\Controller;
use App\ReadModel\<?= $singular ?>ReadModel;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
/**
* Read-only endpoint for the <?= $singular ?> projection.
* Auto-generated by `make:bridge:read-model` — the read-model owns
* the query; this controller just normalises the result to JSON.
*/
final class <?= $singular ?>Controller
{
public function __construct(
private readonly <?= $singular ?>ReadModel $readModel,
) {
}
#[Route('<?= $route ?>', name: '<?= $resource ?>_read', methods: ['GET'])]
public function __invoke(): JsonResponse
{
return new JsonResponse($this->readModel->query());
}
}