make create text method
This commit is contained in:
parent
854771eaa9
commit
72d92debab
1 changed files with 21 additions and 0 deletions
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
namespace App\View;
|
namespace App\View;
|
||||||
|
|
||||||
|
use App\Text\CreateTextDto;
|
||||||
use App\Text\TextRepository;
|
use App\Text\TextRepository;
|
||||||
|
use App\Text\UseCases\CreateText;
|
||||||
|
use App\Text\UseCases\CreateTextRequest;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
|
||||||
class ViewController
|
class ViewController
|
||||||
{
|
{
|
||||||
|
|
@ -34,4 +38,21 @@ class ViewController
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createText(
|
||||||
|
Request $request,
|
||||||
|
Response $response,
|
||||||
|
CreateText $createTextUseCase,
|
||||||
|
): Response {
|
||||||
|
$data = $request->getParsedBody();
|
||||||
|
$name = $data['name'] ?? '';
|
||||||
|
|
||||||
|
if (!empty($name)) {
|
||||||
|
$createTextUseCase->execute(new CreateTextRequest(
|
||||||
|
name: $name,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->withHeader('Location', '/admin/texts')->withStatus(302);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue