src/Troika/RealEstateBundle/Controller/LotController.php line 147

Open in your IDE?
  1. <?php
  2. namespace Troika\RealEstateBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. class LotController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
  7. {
  8.     private function _model($name)
  9.     {
  10.         return $this
  11.           ->container
  12.           ->get($name '.model');
  13.     }
  14.     public function cityAction($id)
  15.     {
  16.         $lot $this
  17.           ->_model('lot')
  18.           ->getByBid($id);
  19.         if ($lot) {
  20.             switch ($lot->getTypeLot()->getId()) {
  21.                 case 1:
  22.                     $url "/elit_kvartiry/";
  23.                     break;
  24.                 case 2:
  25.                     $url "/zagorodnaya_nedvizhimost/";
  26.                     break;
  27.                 case 3:
  28.                     $url "/commercial_nedvigimost/";
  29.                     break;
  30.                 case 4:
  31.                     $url "/zarubezhnaya_nedvizhimost/";
  32.                     break;
  33.             }
  34.             //if ($url) {
  35.             //    $url .= $lot->getId();
  36.             //    return $this->redirect($url, 301);
  37.             //}
  38.         }
  39.         $lot $this
  40.           ->_model('lot')
  41.           ->getForTypeById($id1);
  42.         if (empty($lot)) {
  43.             throw new NotFoundHttpException();
  44.         }
  45.         $similar $this
  46.           ->_model('lot')
  47.           ->getSimilar($lot);
  48.         $ogImg '#';
  49.         $photos $lot->getPhotos();
  50.         if (!empty($photos)) {
  51.             foreach ($photos as $photo) {
  52.                 if ($ogImg === '#') {
  53.                     $ogImg $photo->getWebPathImage();
  54.                     if ($photo->getIsMain()) {
  55.                         break;
  56.                     }
  57.                 } elseif ($photo->getIsMain()) {
  58.                     $ogImg $photo->getWebPathImage();
  59.                     break;
  60.                 }
  61.             }
  62.         }
  63.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  64.         return $this->render(
  65.           'TroikaRealEstateBundle:EstateLot:city.html.twig',
  66.           [
  67.             'ogImg' => $ogImg,
  68.             'lot' => $lot,
  69.             'similar' => $similar,
  70.             'page'=>$page,
  71.             'islot' => true
  72.           ]
  73.         );
  74.     }
  75.     public function cityPdfAction($id)
  76.     {
  77.         $lot $this
  78.           ->_model('lot')
  79.           ->getForTypeById($id1);
  80.         if (!$lot) {
  81.             throw new NotFoundHttpException();
  82.         }
  83.         return $this->render('TroikaRealEstateBundle:EstateLot:city.pdf.twig', ['lot' => $lot]);
  84.     }
  85.     public function cityPdf_Action($id)
  86.     {
  87.         $lot $this
  88.           ->_model('lot')
  89.           ->getForTypeById($id1);
  90.         if (!$lot) {
  91.             throw new NotFoundHttpException();
  92.         }
  93.         return $this->render('TroikaRealEstateBundle:EstateLot:city_new.pdf.twig', ['lot' => $lot]);
  94.     }
  95.     public function commercialAction($id)
  96.     {
  97.         $lot $this
  98.           ->_model('lot')
  99.           ->getByBid($id);
  100.         if ($lot) {
  101.             switch ($lot->getTypeLot()->getId()) {
  102.                 case 1:
  103.                     $url "/elit_kvartiry/";
  104.                     break;
  105.                 case 2:
  106.                     $url "/zagorodnaya_nedvizhimost/";
  107.                     break;
  108.                 case 3:
  109.                     $url "/commercial_nedvigimost/";
  110.                     break;
  111.                 case 4:
  112.                     $url "/zarubezhnaya_nedvizhimost/";
  113.                     break;
  114.             }
  115.             //if ($url) {
  116.             //    $url .= $lot->getId();
  117.             //    return  $this->redirect($url, 301);
  118.             //}
  119.         }
  120.         $lot $this
  121.           ->_model('lot')
  122.           ->getForTypeById($id3);
  123.         if (!$lot) {
  124.             throw new NotFoundHttpException();
  125.         }
  126.         $similar $this
  127.           ->_model('lot')
  128.           ->getSimilarCom($lot);
  129.         $ogImg '';
  130.         foreach ($lot->getPhotos() as $photo) {
  131.             if ($photo->getIsMain()) {
  132.                 $ogImg $photo->getWebPathImage();
  133.             }
  134.         }
  135.         // var_dump($similar->lenght);
  136.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  137.         return $this->render(
  138.           'TroikaRealEstateBundle:EstateLot:commercial.html.twig',
  139.           ['ogImg' => $ogImg'lot' => $lot'similar' => $similar,'page'=>$page,'islot' => true]
  140.         );
  141.     }
  142.     public function commercialPdfAction($id)
  143.     {
  144.         $lot $this
  145.           ->_model('lot')
  146.           ->getForTypeById($id3);
  147.         if (!$lot) {
  148.             throw new NotFoundHttpException();
  149.         }
  150.         return $this->render('TroikaRealEstateBundle:EstateLot:commercial.pdf.twig', ['lot' => $lot]);
  151.     }
  152.     public function commercialPdf_Action($id)
  153.     {
  154.         $lot $this
  155.           ->_model('lot')
  156.           ->getForTypeById($id3);
  157.         if (!$lot) {
  158.             throw new NotFoundHttpException();
  159.         }
  160.         return $this->render('TroikaRealEstateBundle:EstateLot:commercial_new.pdf.twig', ['lot' => $lot]);
  161.     }
  162.     public function favePdfAction(Request $request)
  163.     {
  164.         $lots $request->get('lots');
  165.         $lots $this->container->get('lot.model')->getFave($lots);
  166.         return $this->render('TroikaRealEstateBundle:EstateList:fave.pdf.twig', ['lots' => $lots]);
  167.     }
  168.     public function foreignAction($id)
  169.     {
  170.         $lot $this
  171.           ->_model('lot')
  172.           ->getByBid($id);
  173.         if ($lot) {
  174.             switch ($lot->getTypeLot()->getId()) {
  175.                 case 1:
  176.                     $url "/elit_kvartiry/";
  177.                     break;
  178.                 case 2:
  179.                     $url "/zagorodnaya_nedvizhimost/";
  180.                     break;
  181.                 case 3:
  182.                     $url "/commercial_nedvigimost/";
  183.                     break;
  184.                 case 4:
  185.                     $url "/zarubezhnaya_nedvizhimost/";
  186.                     break;
  187.             }
  188.             //if ($url) {
  189.             //    $url .= $lot->getId();
  190.             //    return $this->redirect($url, 301);
  191.             //}
  192.         }
  193.         $lot $this
  194.           ->_model('lot')
  195.           ->getForTypeById($id4);
  196.         if (!$lot) {
  197.             throw new NotFoundHttpException();
  198.         }
  199.         $similar $this
  200.           ->_model('lot')
  201.           ->getSimilar($lot);
  202.         $ogImg '';
  203.         foreach ($lot->getPhotos() as $photo) {
  204.             if ($photo->getIsMain()) {
  205.                 $ogImg $photo->getWebPathImage();
  206.             }
  207.         }
  208.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  209.         return $this->render('TroikaRealEstateBundle:EstateLot:foreign.html.twig', ['ogImg' => $ogImg'lot' => $lot'similar' => $similar,'page'=>$page,'islot' => true]
  210.         );
  211.     }
  212.     public function foreignPdfAction($id)
  213.     {
  214.         $lot $this
  215.           ->_model('lot')
  216.           ->getForTypeById($id4);
  217.         if (!$lot) {
  218.             throw new NotFoundHttpException();
  219.         }
  220.         return $this->render('TroikaRealEstateBundle:EstateLot:foreign.pdf.twig', ['lot' => $lot]);
  221.     }
  222.     public function foreignPdf_Action($id)
  223.     {
  224.         $lot $this
  225.           ->_model('lot')
  226.           ->getForTypeById($id4);
  227.         if (!$lot) {
  228.             throw new NotFoundHttpException();
  229.         }
  230.         return $this->render('TroikaRealEstateBundle:EstateLot:foreign_new.pdf.twig', ['lot' => $lot]);
  231.     }
  232.     public function suburbanAction($id)
  233.     {
  234.         $lot $this
  235.           ->_model('lot')
  236.           ->getByBid($id);
  237.         if ($lot) {
  238.             switch ($lot->getTypeLot()->getId()) {
  239.                 case 1:
  240.                     $url "/elit_kvartiry/";
  241.                     break;
  242.                 case 2:
  243.                     $url "/zagorodnaya_nedvizhimost/";
  244.                     break;
  245.                 case 3:
  246.                     $url "/commercial_nedvigimost/";
  247.                     break;
  248.                 case 4:
  249.                     $url "/zarubezhnaya_nedvizhimost/";
  250.                     break;
  251.             }
  252.             //if ($url) {
  253.             //    $url .= $lot->getId();
  254.             //    return $this->redirect($url, 301);
  255.             //}
  256.         }
  257.         if ($id == 851) {
  258.             return $this->redirect("/zagorodnaya_nedvizhimost/1019/"301);
  259.         }
  260.         $lot $this
  261.           ->_model('lot')
  262.           ->getForTypeById($id2);
  263.         if (!$lot) {
  264.             throw new NotFoundHttpException();
  265.         }
  266.         $similar $this
  267.           ->_model('lot')
  268.           ->getSimilar($lot);
  269.         $ogImg '';
  270.         foreach ($lot->getPhotos() as $photo) {
  271.             if ($photo->getIsMain()) {
  272.                 $ogImg $photo->getWebPathImage();
  273.             }
  274.         }
  275.         $page $this->getDoctrine()->getRepository('TroikaMainBundle:MainPage')->find(2);
  276.         return $this->render(
  277.           'TroikaRealEstateBundle:EstateLot:suburban.html.twig',
  278.           ['ogImg' => $ogImg'lot' => $lot'similar' => $similar,'page'=>$page,'islot' => true]
  279.         );
  280.     }
  281.     public function suburbanPdfAction($id)
  282.     {
  283.         $lot $this
  284.           ->_model('lot')
  285.           ->getForTypeById($id2);
  286.         if (!$lot) {
  287.             throw new NotFoundHttpException();
  288.         }
  289.         return $this->render('TroikaRealEstateBundle:EstateLot:suburban.pdf.twig', ['lot' => $lot]);
  290.     }
  291.     public function suburbanPdf_Action($id)
  292.     {
  293.         $lot $this
  294.           ->_model('lot')
  295.           ->getForTypeById($id2);
  296.         if (!$lot) {
  297.             throw new NotFoundHttpException();
  298.         }
  299.         return $this->render('TroikaRealEstateBundle:EstateLot:suburban_new.pdf.twig', ['lot' => $lot]);
  300.     }
  301. }