Handle creating a channel.

This commit is contained in:
Dave Smith-Hayes 2024-12-14 09:24:29 -05:00
parent b69b29e54a
commit bc9997a817
3 changed files with 47 additions and 0 deletions

View 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);
}
}
}

View File

@ -2,6 +2,7 @@
namespace Slovocast\Controller\Channel; namespace Slovocast\Controller\Channel;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Slovocast\Controller\Controller; use Slovocast\Controller\Controller;

View File

@ -15,6 +15,24 @@
<textarea name="description"></textarea> <textarea name="description"></textarea>
</div> </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> <div>
<button type="submit">Create</button> <button type="submit">Create</button>
</div> </div>