src/Troika/RealEstateBundle/Controller/FilterPresetController.php line 22

Open in your IDE?
  1. <?php
  2. namespace Troika\RealEstateBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  5. class FilterPresetController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
  6. {
  7.     private function _model($name)
  8.     {
  9.         return $this
  10.           ->container
  11.           ->get($name '.model');
  12.     }
  13.     public function CustomFilterAction($alias)
  14.     {
  15.         $em $this->getDoctrine()->getEntityManager();
  16.         $filter $em->getRepository('TroikaMainBundle:FilterPreset')->findOneBy(['alias' => $alias]);
  17.         if ($filter) {
  18.             $lots $this->_model('lot')->getEmptyPage();
  19.             if ($filter->getTypeLot() && !$filter->getExclusive()) {
  20.                 switch ($filter->getTypeLot()->getId()) {
  21.                     case 1:
  22.                         $data = [
  23.                           'lots'          => $lots,
  24.                           'lotsAddresses' => $this->_model('lot')->getLotAddresses(11),
  25.                           'subways'       => $this->_model('subway')->getAll2(),
  26.                           'districts'     => $this->_model('district')->getAll2(),
  27.                           'types'         => $this->_model('type_house')->getByType(1),
  28.                           'stages'        => $this->_model('stage_house')->getAll(),
  29.                           'filterpreset'  => $filter->getAttributes(),
  30.                         ];
  31.                         return $this->render('TroikaRealEstateBundle:EstateList:city.html.twig'$data);
  32.                         break;
  33.                     case 4:
  34.                         $data = [
  35.                           'lots'          => $lots,
  36.                           'lotsAddresses' => $this->_model('lot')->getLotAddresses(41),
  37.                           'countries'     => $this->_model('country')->getAll(),
  38.                           'countryCities' => $this->_model('country_city')->getAll(),
  39.                           'types'         => $this->_model('type_house')->getByType(4),
  40.                           'stages'        => $this->_model('stage_house')->getAll(),
  41.                           'filterpreset'  => $filter->getAttributes(),
  42.                         ];
  43.                         return $this->render('TroikaRealEstateBundle:EstateList:foreign.html.twig'$data);
  44.                         break;
  45.                     case 2:
  46.                         $data = [
  47.                           'lots'          => $lots,
  48.                           'lotsAddresses' => $this->_model('lot')->getLotAddresses(22),
  49.                           'highways'      => $this->_model('highway')->getAll(),
  50.                           'settlements'   => $this->_model('settlement')->getAll(),
  51.                           'types'         => $this->_model('type_house')->getByType(2),
  52.                           'stages'        => $this->_model('stage_house')->getAll(),
  53.                           'filterpreset'  => $filter->getAttributes(),
  54.                         ];
  55.                         return $this->render('TroikaRealEstateBundle:EstateList:suburban.html.twig'$data);
  56.                         break;
  57.                     case 3:
  58.                         $data = [
  59.                           'lots'          => $lots,
  60.                           'lotsAddresses' => $this->_model('lot')->getLotAddresses(32),
  61.                           'subways'       => $this->_model('subway')->getAll2(),
  62.                           'districts'     => $this->_model('district')->getAll2(),
  63.                           'types'         => $this->_model('type_house')->getByType(3),
  64.                           'stages'        => $this->_model('stage_house')->getAll(),
  65.                           'filterpreset'  => $filter->getAttributes(),
  66.                         ];
  67.                         return $this->render('TroikaRealEstateBundle:EstateList:commercial.html.twig'$data);
  68.                         break;
  69.                 }
  70.             } elseif ($filter->getExclusive()) {
  71.                 $data = [
  72.                   'lots'          => $lots,
  73.                   'lotsAddresses' => $this->_model('lot')->getLotAddresses(32),
  74.                   'subways'       => $this->_model('subway')->getAll2(),
  75.                   'districts'     => $this->_model('district')->getAll2(),
  76.                   'types'         => $this->_model('type_house')->getByType(3),
  77.                   'stages'        => $this->_model('stage_house')->getAll(),
  78.                   'filterpreset'  => $filter->getAttributes(),
  79.                 ];
  80.                 return $this->render('@TroikaRealEstate/EstateList/special.html.twig'$data);
  81.             }
  82.         } else {
  83.             throw new NotFoundHttpException();
  84.         }
  85.     }
  86.     public function SuburbanCustomFilterAction($alias)
  87.     {
  88.         exit;
  89.         $em $this->getDoctrine()->getEntityManager();
  90.         $filter $em->getRepository('TroikaMainBundle:FilterPreset')->findOneBy(['alias' => $alias]);
  91.         if ($filter) {
  92.             $lots $this->_model('lot')->getEmptyPage();
  93.             if ($filter->getTypeLot() && !$filter->getExclusive()) {
  94.                 switch ($filter->getTypeLot()->getId()) {
  95.                     case 2:
  96.                         $data = [
  97.                           'lots'          => $lots,
  98.                           'lotsAddresses' => $this->_model('lot')->getLotAddresses(22),
  99.                           'highways'      => $this->_model('highway')->getAll(),
  100.                           'settlements'   => $this->_model('settlement')->getAll(),
  101.                           'types'         => $this->_model('type_house')->getByType(2),
  102.                           'stages'        => $this->_model('stage_house')->getAll(),
  103.                           'filterpreset'  => $filter->getAttributes(),
  104.                         ];
  105.                         return $this->render('TroikaRealEstateBundle:EstateList:suburban.html.twig'$data);
  106.                         break;
  107.                     default:
  108.                         throw new NotFoundHttpException();
  109.                         break;
  110.                 }
  111.             }
  112.         } else {
  113.             throw new NotFoundHttpException();
  114.         }
  115.     }
  116. }