src/Common/CoreBundle/Controller/DefaultController.php line 102

Open in your IDE?
  1. <?php
  2. namespace Common\CoreBundle\Controller;
  3. use Front\FormationsBundle\Form\Type\InscritsType;
  4. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  5. use Symfony\Component\HttpFoundation\Request;
  6. class DefaultController extends Controller
  7. {
  8.     public function indexAction()
  9.     {
  10.         $em $this->getDoctrine()->getManager();
  11.         /** @var HomesSlider $sliders */
  12.         $sliders $em->getRepository("FrontCmsBundle:HomeSlider")->findBy(array('active' => 1));
  13.         /* $userHandler = $this->container->get('common.core.user_handler');
  14.           $userHandler->editRoles( [
  15.           0 => "ROLE_SUPER_ADMIN",
  16.           1 => "ROLE_ADMIN",
  17.           2 => "ROLE_SONATA_ADMIN",
  18.           3 => "ROLE_USER"
  19.           ], $this->getUser());
  20.           dump($this->getUser()); */
  21.         //$rubriques = $em->getRepository("ManuscritBundle:Rubrique")->findAll();
  22.         return $this->render('CommonCoreBundle:Default:index.html.twig', [
  23.             'sliders' => $sliders
  24.             //'rubriques' => $rubriques
  25.         ]);
  26.     }
  27.     public function revueAction()
  28.     {
  29.         return $this->render('CommonCoreBundle:Default:index.html.twig');
  30.     }
  31.     public function subscribeBtnAction()
  32.     {
  33.         $em $this->getDoctrine()->getManager();
  34.         if ($this->getUser()) {
  35.             $Subscription $em->getRepository('EcommerceBundle:Subscription')->getSubscriptionByUser($this->getUser()->getId());
  36.         } else {
  37.             $Subscription false;
  38.         }
  39.         return $this->render('CommonCoreBundle:Default:subscribeBtn.html.twig', ['Subscription' => $Subscription]);
  40.     }
  41.     public function checkSubscribeBtnAction()
  42.     {
  43.         $em $this->getDoctrine()->getManager();
  44.         if ($this->getUser()) {
  45.             $Subscription $em->getRepository('EcommerceBundle:Subscription')->getSubscriptionByUser($this->getUser()->getId());
  46.         } else {
  47.             $Subscription false;
  48.         }
  49.         return $Subscription;
  50.     }
  51.     public function recentFormationsAction(Request $request$max 5)
  52.     {
  53.         $em $this->getDoctrine()->getManager();
  54.         $formations $em->getRepository('FrontFormationsBundle:Formations')
  55.             ->createQueryBuilder('f')
  56.             ->where('f.isValidate = true')
  57.             ->leftJoin('f.status''s''f.id = s.formations')
  58.             ->andwhere('s.label = :status')
  59.             ->orderBy('f.dateStart''DESC')
  60.             ->setParameter('status''Mise en ligne')
  61.             ->getQuery()
  62.             ->setMaxResults($max)
  63.             ->getResult();
  64.         $subscription $this->checkSubscribeBtnAction();
  65.         return $this->render('CommonCoreBundle:Default:recent_formations.html.twig', array(
  66.             'formations' => $formations,
  67.             'subscription' => $subscription,
  68.         ));
  69.     }
  70.     public function recentFreeAction(Request $request$max 5)
  71.     {
  72.         $em $this->getDoctrine()->getManager();
  73.         $articles $em->getRepository('ManuscritBundle:Manuscrit')
  74.             ->createQueryBuilder('m')
  75.             ->where('m.isFree = true')
  76.             ->leftJoin('ManuscritBundle:Revue''r''WITH''r.id = m.revue')
  77.             ->andWhere('m.revue IS NOT NULL')
  78.             ->andwhere('r.published=true')
  79.             ->orderBy('r.number''DESC')
  80.             ->getQuery()
  81.             ->setMaxResults($max)
  82.             ->getResult();
  83.         return $this->render('CommonCoreBundle:Default:recent_free.html.twig', array(
  84.             'articles' => $articles
  85.         ));
  86.     }
  87.     public function newsletterAction(Request $request$position 'newsletter'$group 'newsletter')
  88.     {
  89.         return $this->render('CommonCoreBundle:Default:newsletter.html.twig', array(
  90.             'group' => $group,
  91.             'position' => $position
  92.         ));
  93.     }
  94. }