src/Controller/DefaultController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Repository\PageRepository;
  7. use App\Repository\PostRepository;
  8. use App\Entity\Page;
  9. use App\Entity\Tag;
  10. use App\Entity\TextFragment;
  11. class DefaultController extends AbstractController
  12. {
  13.      
  14.     
  15.     /**
  16.      * @Route("/admin/tutorials/", name="tutorials")
  17.      */
  18.     public function tutorials($name=null): Response
  19.     {
  20.         return $this->render('default/tutorials.html.twig'); 
  21.     }
  22.     
  23.     
  24.   
  25.     
  26.     /**
  27.      * @Route("/", defaults={"name" = null}, name="default")
  28.      */
  29.     public function index($name=null): Response
  30.     {
  31.         return $this->render('st/index.html.twig');
  32.     }
  33.     
  34.     
  35.     
  36.     /**
  37.      * @Route("/fg/{id}", name="fragment", defaults={"id" = null})
  38.      */
  39.     public function fg($id=null): Response
  40.     {
  41.         
  42.         
  43.         $fragment $this->getDoctrine()
  44.         ->getRepository(TextFragment::class)
  45.         ->findOneBy(['id' => $id]);
  46.         
  47.       
  48.         
  49.         $data $fragment->getTextNl();
  50.         
  51.         $response = new Response();
  52.         //$response->headers->set('Content-type', 'application/json');
  53.         $response->setContent($data);
  54.         
  55.         return $response;
  56.         
  57.         /*@
  58.         return $this->render('st/group.html.twig', [
  59.             'group' => $group,
  60.             
  61.         ]);
  62.         */
  63.         
  64.         
  65.     }
  66.     
  67.     
  68.     
  69.     /**
  70.      * @Route("/group/{name}/{id}", defaults={"name" = null,"id" = null})
  71.      */
  72.     public function group($name=null,$idnull): Response
  73.     {
  74.     
  75.         
  76.         $group $this->getDoctrine()
  77.         ->getRepository(Tag::class)
  78.         ->findOneBy(['id' => $id]);
  79.         
  80.         // open de group
  81.         //geef ook alle products van die group meteen...
  82.         
  83.     
  84.     return $this->render('st/group.html.twig', [
  85.         'group' => $group,
  86.        
  87.     ]);
  88.     
  89.     
  90.     }
  91.     
  92.     
  93.     
  94.     /**
  95.      * @Route("/nl/{name}", defaults={"name" = null})
  96.      * @Route("/fr/{name}", defaults={"name" = null})
  97.      * @Route("/en/{name}", defaults={"name" = null})
  98.      * @Route("/de/{name}", defaults={"name" = null})
  99.      */
  100.     public function page($name=null): Response
  101.     {
  102.        
  103.         $page $this->getDoctrine()
  104.         ->getRepository(Page::class)
  105.         ->findOneBy(['name' => $name]);
  106.         
  107.         
  108.         if($page){
  109.             $template "st/".$page->getTemplate().".html.twig";
  110.             
  111.         }else{
  112.             $template "st/notfound.html.twig";
  113.         }
  114.        
  115.         return $this->render($template);
  116.         
  117.         
  118.        // return $this->render('st/'.$name.'.html.twig');
  119.         
  120.         
  121.         
  122.         
  123.     }
  124.     
  125.     
  126.     
  127.     
  128.     
  129.     /**
  130.      * @Route("/dashboard/", name="default_loggedin")
  131.      */
  132.     public function loggedin(): Response
  133.     {
  134.         return $this->render('default/loggedin.html.twig', [
  135.             'controller_name' => 'DefaultController',
  136.         ]);
  137.     }
  138.     
  139.     
  140.     
  141. }