30 lines
769 B
PHP
30 lines
769 B
PHP
|
|
<?= "<?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());
|
||
|
|
}
|
||
|
|
}
|