src/Controller/Frontend/EventsController.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use App\Service\TextHelper;
  10. use App\Service\UrlHelper;
  11. use App\Entity\News;
  12. use App\Entity\File;
  13. use App\Entity\Section;
  14. class EventsController extends AbstractController {
  15.     public function __construct() {
  16.         // echo 'We can use __contruct<br />';
  17.     }
  18.     /**
  19.      * @Route(
  20.      *   {
  21.      *       "es" : "{_locale}/eventos/agenda",
  22.      *       "ca" : "{_locale}/esdeveniments/agenda",
  23.      *       "en" : "{_locale}/events/schedule",
  24.      *    }, name="events",
  25.      *       requirements={
  26.      *          "_locale": "es|ca|en",
  27.      *          "_format" : "html"
  28.      *      }
  29.      * )
  30.      */
  31.     public function index(Request $requestTextHelper $textHelperUrlHelper $urlHelper) {
  32.         $oneSection $this->getDoctrine()->getRepository(Section::Class)->findOneBy(['code' => 'events']);
  33.         $text = ($textHelper->getBySection($oneSection)) ? $textHelper->getBySection($oneSection) : [];
  34.         $eventAddFiles = [];
  35.         $records $this->getDoctrine()->getRepository(News::class)->findBy(['active' => 1], ['sort' => 'ASC']);
  36.         if ($records) {
  37.             foreach ($records as $key => $record) {
  38.                 $image $this->getDoctrine()->getRepository(File::class)->findOneBy(array('itemId' => $record->getId(), 'section' => 'news''type' => 'mainImage'), ['sort' => 'ASC']);
  39.                 $eventAddFiles[$key]['mainImage'] = ($image) ? $urlHelper->createImageUrl('news'$record->getId(), 'resized'$image->getId(), 'backendGallery'$image->getExtension()) : null;
  40.                 $eventAddFiles[$key]['record'] = $record;
  41.             }
  42.         }
  43.         return $this->render('Frontend/events/events.html.twig', ['events' => $eventAddFiles'text' => $text'oneSection' => $oneSection]);
  44.     }
  45.     /**
  46.      * @Route(
  47.      *   {
  48.      *       "es" : "{_locale}/eventos",
  49.      *       "ca" : "{_locale}/esdeveniments",
  50.      *       "en" : "{_locale}/events",
  51.      *    }, name="eventosorganiza",
  52.      *       requirements={
  53.      *          "_locale": "es|ca|en",
  54.      *          "_format" : "html"
  55.      *      }
  56.      * )
  57.      */
  58.     public function eventosorganiza(Request $requestTextHelper $textHelper) {
  59.         $oneSection $this->getDoctrine()->getRepository(Section::Class)->findOneBy(['code' => 'eventosorganiza']);
  60.         $text = ($textHelper->getBySection($oneSection)) ? $textHelper->getBySection($oneSection) : [];
  61.         return $this->render('Frontend/events/eventsorganiza.html.twig', ['text' => $text'oneSection' => $oneSection]);
  62.     }
  63. }