Get the channels for a user on the dashboad.
This commit is contained in:
parent
b9db0d97dc
commit
83cc9b194c
@ -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.");
|
||||
}
|
||||
}
|
||||
|
@ -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 ]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user