<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints\DateTime;
use App\Utils\Constants;
use App\Utils\Breadcrumbs;
use App\Utils\Utils;
use App\Entity\Setting;
use App\Entity\Organisation;
use App\Entity\TrainingMaterial;
use App\Entity\FAQ;
use App\Entity\SupportQuery;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
/**
* Require ROLE_USER for *every* controller method in this class.
*
* @IsGranted("ROLE_USER")
*/
class HomeController extends AbstractController
{
/**
* @Route("/home", name="home")
* @IsGranted("ROLE_USER")
*/
public function index(Request $request, \Swift_Mailer $mailer)
{
// $hasAccess = $this->isGranted('ROLE_USER');
// $this->denyAccessUnlessGranted('ROLE_USER');
if($this->isGranted('ROLE_SUPER_USER')) {
$this->addFlash('error','Access Denied');
return $this->redirectToRoute('error');
}
$user = $this->getUser();
if($user->getOrganisations()->count() <= 0) {
$this->addFlash('error','Organisation not found.');
return $this->redirectToRoute('error');
}
$orgId = $user->getOrganisations()->first()->getId();
$org = $user->getOrganisations()->first();
$constants = new Constants();
$firstBreadcrumb = Breadcrumbs::getFirstBreadcrumb($this->getDoctrine(), $user, $request);
$backLinkLabel = "Home";
$backLink = "/home";
$breadcrumbs[$firstBreadcrumb] = "/";
$breadcrumbs[$backLinkLabel] = $backLink;
$calink = Utils::buildCASwitchLink($this);
$culink = Utils::buildCULink($this, "/home");
return $this->render('cu/home.html.twig', array(
// 'form' => $form->createView(),
'page_heading' => $backLinkLabel,
'constants' => $constants,
'breadcrumbs' => $breadcrumbs,
'user' => $user,
'backlink' => $backLink,
'backlink_label' => $backLinkLabel,
'calink' => $calink,
'culink' => $culink,
));
}
}