add getText method to text controller

This commit is contained in:
Yisroel Baum 2026-04-17 09:54:21 +03:00
parent 4fe10214d5
commit 85ab8f2bbc
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -29,6 +29,21 @@ class TextController
return $response->withHeader('Content-Type', 'application/json');
}
public function getText(Response $response, int $textId): Response
{
$text = $this->textRepository->find($textId);
if ($text === null) {
return $response->withStatus(404);
}
$response->getBody()->write(json_encode([
'id' => $text->getId(),
'name' => $text->getName(),
]));
return $response->withHeader('Content-Type', 'application/json');
}
public function createText(
Request $request,
Response $response,