<?php
namespace Common\CoreBundle\Controller;
use Front\FormationsBundle\Form\Type\InscritsType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
/** @var HomesSlider $sliders */
$sliders = $em->getRepository("FrontCmsBundle:HomeSlider")->findBy(array('active' => 1));
/* $userHandler = $this->container->get('common.core.user_handler');
$userHandler->editRoles( [
0 => "ROLE_SUPER_ADMIN",
1 => "ROLE_ADMIN",
2 => "ROLE_SONATA_ADMIN",
3 => "ROLE_USER"
], $this->getUser());
dump($this->getUser()); */
//$rubriques = $em->getRepository("ManuscritBundle:Rubrique")->findAll();
return $this->render('CommonCoreBundle:Default:index.html.twig', [
'sliders' => $sliders
//'rubriques' => $rubriques
]);
}
public function revueAction()
{
return $this->render('CommonCoreBundle:Default:index.html.twig');
}
public function subscribeBtnAction()
{
$em = $this->getDoctrine()->getManager();
if ($this->getUser()) {
$Subscription = $em->getRepository('EcommerceBundle:Subscription')->getSubscriptionByUser($this->getUser()->getId());
} else {
$Subscription = false;
}
return $this->render('CommonCoreBundle:Default:subscribeBtn.html.twig', ['Subscription' => $Subscription]);
}
public function checkSubscribeBtnAction()
{
$em = $this->getDoctrine()->getManager();
if ($this->getUser()) {
$Subscription = $em->getRepository('EcommerceBundle:Subscription')->getSubscriptionByUser($this->getUser()->getId());
} else {
$Subscription = false;
}
return $Subscription;
}
public function recentFormationsAction(Request $request, $max = 5)
{
$em = $this->getDoctrine()->getManager();
$formations = $em->getRepository('FrontFormationsBundle:Formations')
->createQueryBuilder('f')
->where('f.isValidate = true')
->leftJoin('f.status', 's', 'f.id = s.formations')
->andwhere('s.label = :status')
->orderBy('f.dateStart', 'DESC')
->setParameter('status', 'Mise en ligne')
->getQuery()
->setMaxResults($max)
->getResult();
$subscription = $this->checkSubscribeBtnAction();
return $this->render('CommonCoreBundle:Default:recent_formations.html.twig', array(
'formations' => $formations,
'subscription' => $subscription,
));
}
public function recentFreeAction(Request $request, $max = 5)
{
$em = $this->getDoctrine()->getManager();
$articles = $em->getRepository('ManuscritBundle:Manuscrit')
->createQueryBuilder('m')
->where('m.isFree = true')
->leftJoin('ManuscritBundle:Revue', 'r', 'WITH', 'r.id = m.revue')
->andWhere('m.revue IS NOT NULL')
->andwhere('r.published=true')
->orderBy('r.number', 'DESC')
->getQuery()
->setMaxResults($max)
->getResult();
return $this->render('CommonCoreBundle:Default:recent_free.html.twig', array(
'articles' => $articles
));
}
public function newsletterAction(Request $request, $position = 'newsletter', $group = 'newsletter')
{
return $this->render('CommonCoreBundle:Default:newsletter.html.twig', array(
'group' => $group,
'position' => $position
));
}
}