add getText method to text controller
This commit is contained in:
parent
4fe10214d5
commit
85ab8f2bbc
1 changed files with 15 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue