src\Controller\BaseController.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Produit;
  4. use App\Entity\Publicite;
  5. use App\Entity\Service;
  6. use App\Entity\Typenews;
  7. use App\Entity\Video;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class BaseController extends AbstractController
  12. {
  13.     /**
  14.      * Renders a view.
  15.      *
  16.      * @final
  17.      */
  18.     protected function render(string $view, array $parameters = [], Response $response null): Response
  19.     {
  20.         $doctrine=$this->getDoctrine();
  21.         $parameters['services'] = $doctrine->getRepository(Service::class)->findAll();
  22.         $parameters['publicites'] = $doctrine->getRepository(Publicite::class)->findAll();
  23.         $parameters['produits'] = $doctrine->getRepository(Produit::class)->findAll();
  24.         $parameters['videos'] = $doctrine->getRepository(Video::class)->findAll();
  25.         $parameters['typesnews'] = $doctrine->getRepository(Typenews::class)->findAll();
  26.         //dd($parameters);
  27.         if ($this->container->has('templating')) {
  28.             @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.'E_USER_DEPRECATED);
  29.             $content $this->container->get('templating')->render($view$parameters);
  30.         } elseif ($this->container->has('twig')) {
  31.             $content $this->container->get('twig')->render($view$parameters);
  32.         } else {
  33.             throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
  34.         }
  35.         if (null === $response) {
  36.             $response = new Response();
  37.         }
  38.         $response->setContent($content);
  39.         return $response;
  40.     }
  41. /*    private function initData()
  42.     {
  43.         $doctrine=$this->getDoctrine();
  44.         $this->base_service=$doctrine->getRepository(Service::class)->findAll();
  45.         $this->base_publicite = $doctrine->getRepository(Publicite::class)->findAll();
  46.         $this->base_produit = $doctrine->getRepository(Produit::class)->findAll();
  47.         $this->base_video = $doctrine->getRepository(Video::class)->findAll();
  48.         $this->base_typenews = $doctrine->getRepository(Typenews::class)->findAll();
  49.     }*/
  50. }