diff --git a/app/src/Controller/Channel/CreateChannelAction.php b/app/src/Controller/Channel/CreateChannelAction.php index d6b5a8e..ff279f6 100644 --- a/app/src/Controller/Channel/CreateChannelAction.php +++ b/app/src/Controller/Channel/CreateChannelAction.php @@ -37,10 +37,14 @@ class CreateChannelAction extends Controller /** * Should wrap this in a try/catch probably */ - if (!$this->channelRepository->create($channel, $user)) { - return $this->render('channel/create.twig')->withStatus(500); + 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); } - - $this->session->getFlash()->add("success", "Successfully created new channel."); } } diff --git a/app/src/Controller/DashboardPage.php b/app/src/Controller/DashboardPage.php index 201ed23..6019a65 100644 --- a/app/src/Controller/DashboardPage.php +++ b/app/src/Controller/DashboardPage.php @@ -3,6 +3,7 @@ namespace Slovocast\Controller; use Odan\Session\SessionInterface; +use Slovocast\Domain\Entity\User; use Slovocast\Domain\Repository\Channel\ChannelRepositoryInterface; use Slovocast\Domain\Repository\User\UserRepositoryInterface; use Psr\Http\Message\ResponseInterface as Response; @@ -19,6 +20,9 @@ class DashboardPage extends Controller { // get the user details // get the channels - return $this->render('dashboard.twig'); + $userData = $this->session->get("user"); + $user = User::fromArray($userData); + $channels = $this->channelRepository->getFromUser($user); + return $this->render('dashboard.twig', [ 'channel' => $channels ]); } }