Compare commits
No commits in common. "d5bc01f6bdbae93304755d12bff25c5f459d6a56" and "d4e31baed0d1fb78ff23cb6bbbb8ff6771f1a831" have entirely different histories.
d5bc01f6bd
...
d4e31baed0
5 changed files with 4 additions and 28 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
|||
vendor/
|
||||
node_modules/
|
||||
data/
|
||||
|
|
@ -2,12 +2,8 @@
|
|||
|
||||
namespace App\View;
|
||||
|
||||
use App\Text\CreateTextDto;
|
||||
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\ServerRequestInterface as Request;
|
||||
|
||||
class ViewController
|
||||
{
|
||||
|
|
@ -38,21 +34,4 @@ class ViewController
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,5 @@ $app->addErrorMiddleware(true, true, true);
|
|||
|
||||
$app->get('/admin', [ViewController::class, 'admin']);
|
||||
$app->get('/admin/texts', [ViewController::class, 'texts']);
|
||||
$app->post('/admin/texts', [ViewController::class, 'createText']);
|
||||
|
||||
return $app;
|
||||
|
|
|
|||
1
data/texts.json
Normal file
1
data/texts.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -9,9 +9,7 @@
|
|||
<ul id="texts-list">
|
||||
{{texts}}
|
||||
</ul>
|
||||
<form action="/admin/texts" method="POST">
|
||||
<input id="newTextName" name="name"/>
|
||||
<input id="newTextName"/>
|
||||
<button id="submit">submit</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue