Compare commits
No commits in common. "83cc9b194c9d96e5cc319798b8006512f0b91374" and "bc9997a81703391d3ef88303b780f2e74d1bcae6" have entirely different histories.
83cc9b194c
...
bc9997a817
@ -6,16 +6,12 @@ use Odan\Session\SessionInterface;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Slovocast\Controller\Controller;
|
use Slovocast\Controller\Controller;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface;
|
|
||||||
use Slovocast\Domain\Entity\Channel;
|
|
||||||
use Slovocast\Domain\Entity\User;
|
|
||||||
|
|
||||||
class CreateChannelAction extends Controller
|
class CreateChannelAction extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected SessionInterface $session,
|
protected SessionInterface $session,
|
||||||
protected LoggerInterface $logger,
|
protected LoggerInterface $logger,
|
||||||
protected ChannelRepositoryInterface $channelRepository
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
public function handle(): Response
|
public function handle(): Response
|
||||||
@ -28,23 +24,5 @@ class CreateChannelAction extends Controller
|
|||||||
$this->logger->error("Session User ID and Form User ID do no match.");
|
$this->logger->error("Session User ID and Form User ID do no match.");
|
||||||
return $this->render('channel/create.twig')->withStatus(400);
|
return $this->render('channel/create.twig')->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$formData['explicit'] = $formData['explicit'] === "yes" ? true : false;
|
|
||||||
|
|
||||||
$user = User::fromArray($userData);
|
|
||||||
$channel = Channel::fromArray($formData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should wrap this in a try/catch probably
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
$channel = $this->channelRepository->create($channel, $user);
|
|
||||||
$this->session->getFlash()->add("success", "Created new channel.");
|
|
||||||
return $this->redirect("/dashboard", 302);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->logger->error($e->getMessage());
|
|
||||||
$this->session->getFlash()->add("error", "Unable to create new channel.");
|
|
||||||
return $this->render('channe/create.twig')->withStatus(500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace Slovocast\Controller;
|
namespace Slovocast\Controller;
|
||||||
|
|
||||||
use Odan\Session\SessionInterface;
|
use Odan\Session\SessionInterface;
|
||||||
use Slovocast\Domain\Entity\User;
|
|
||||||
use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface;
|
use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface;
|
||||||
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
use Slovocast\Domain\Repository\User\UserRepositoryInterface;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
@ -20,9 +19,6 @@ class DashboardPage extends Controller
|
|||||||
{
|
{
|
||||||
// get the user details
|
// get the user details
|
||||||
// get the channels
|
// get the channels
|
||||||
$userData = $this->session->get("user");
|
return $this->render('dashboard.twig');
|
||||||
$user = User::fromArray($userData);
|
|
||||||
$channels = $this->channelRepository->getFromUser($user);
|
|
||||||
return $this->render('dashboard.twig', [ 'channel' => $channels ]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user