Handle creating a channel.
This commit is contained in:
parent
b69b29e54a
commit
bc9997a817
28
app/src/Controller/Channel/CreateChannelAction.php
Normal file
28
app/src/Controller/Channel/CreateChannelAction.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Controller\Channel;
|
||||
|
||||
use Odan\Session\SessionInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Slovocast\Controller\Controller;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
|
||||
class CreateChannelAction extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected SessionInterface $session,
|
||||
protected LoggerInterface $logger,
|
||||
) { }
|
||||
|
||||
public function handle(): Response
|
||||
{
|
||||
$userData = $this->session->get('user');
|
||||
$formData = $this->request->getParsedBody();
|
||||
|
||||
if ($userData['id'] !== $formData['user_id']) {
|
||||
$this->session->getFlash()->add("error", "Unable to create channel.");
|
||||
$this->logger->error("Session User ID and Form User ID do no match.");
|
||||
return $this->render('channel/create.twig')->withStatus(400);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Slovocast\Controller\Channel;
|
||||
|
||||
use Odan\Session\SessionInterface;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Slovocast\Controller\Controller;
|
||||
|
||||
|
@ -15,6 +15,24 @@
|
||||
<textarea name="description"></textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="country_code">Country<br>
|
||||
<input type="text" name="country_code" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="category">Category<br>
|
||||
<input type="text" name="category" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="explicit">Explicit<br>
|
||||
<select>
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit">Create</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user