src/AppBundle/Controller/NewsController.php line 109

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Controller;
  3. use Pimcore\Controller\FrontendController;
  4. use Pimcore\Model\DataObject\Akcii;
  5. use Pimcore\Model\DataObject\Budni;
  6. use Pimcore\Model\DataObject\Trenery;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Zend\Paginator\Paginator;
  9. class NewsController extends FrontendController
  10. {
  11.     // КОНТРОЛЕР АКЦИЙ
  12.     public function akciiAction(Request $request)
  13.     {
  14.         $actionsList = new Akcii\Listing();
  15.         $val 'cross';
  16.         if(strstr($request->getRequestUri(), 'akcii-fitness-energy')) {
  17.             $val 'fitness';     
  18.         } 
  19.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  20.         $actionsList->setCondition($where_str);
  21.         $actionsList->setOrderKey('dateSort');
  22.         $paginator = new Paginator($actionsList);
  23.         $paginator->setCurrentPageNumber($request->get('page'));
  24.         $paginator->setItemCountPerPage(8);
  25.         $this->view->listCount $actionsList->count();
  26.         $this->view->paginator $paginator;
  27.     }
  28.     public function showAkciiAction(Request $request)
  29.     {   
  30.         $docPath $request->getPathInfo();
  31.         //    "id" is the named parameters in "Static Routes"
  32.         $object Akcii::getByPath($docPath);
  33.         if (!$object instanceof Akcii || !$object->isPublished()) {
  34.         //        this will trigger a 404 error response
  35.             throw $this->createNotFoundException('Invalid request');
  36.         }
  37.         $this->view->Akcii $object;
  38.     }
  39.     // КОНТРОЛЕР БУДНЕЙ
  40.     public function budniAction(Request $request)
  41.     {
  42.         // get a list of news objects and order them by date
  43.         $budniList = new Budni\Listing();
  44.         $val 'cross';
  45.         if(strstr($request->getRequestUri(), 'budni-fitness-energy')) {
  46.             $val 'fitness';     
  47.         } 
  48.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  49.         $budniList->setCondition($where_str);
  50.         $budniList->setOrderKey('dateSort');
  51.         $budniList->setOrder('desc');
  52.         $paginator = new Paginator($budniList);
  53.         $paginator->setCurrentPageNumber($request->get('page'));
  54.         $paginator->setItemCountPerPage(9);
  55.         $this->view->listCount $budniList->count();
  56.         $this->view->paginator $paginator;
  57.     }
  58.     public function showBudniAction(Request $request)
  59.     {   
  60.         $docPath $request->getPathInfo();
  61.         //    "id" is the named parameters in "Static Routes"
  62.         $object Budni::getByPath($docPath);
  63.         if (!$object instanceof Budni || !$object->isPublished()) {
  64.         //        this will trigger a 404 error response
  65.             throw $this->createNotFoundException('Invalid request');
  66.         }
  67.         $this->view->Budni $object;
  68.     }
  69.     // КОНТРОЛЕР ТРЕНЕРОВ
  70.     public function treneryAction(Request $request)
  71.     {
  72.         $treneryList = new Trenery\Listing();
  73.         $val 'cross';
  74.         if(strstr($request->getRequestUri(), 'komanda-fitness-energy')) {
  75.             $val 'fitness';     
  76.         } 
  77.         $where_str "branch LIKE '%$val%' or branch LIKE 'all'";
  78.         $treneryList->setCondition($where_str);
  79.         $treneryList->setOrderKey('dateSort');
  80.         $paginator = new Paginator($treneryList);
  81.         $paginator->setCurrentPageNumber($request->get('page'));
  82.         $paginator->setItemCountPerPage(40);
  83.         $this->view->listCount $treneryList->count();
  84.         $this->view->paginator $paginator;
  85.     }
  86.     public function showTreneryAction(Request $request) {   
  87.         $docPath $request->getPathInfo();
  88.         //    "id" is the named parameters in "Static Routes"
  89.         $object Trenery::getByPath($docPath);
  90.         if (!$object instanceof Trenery || !$object->isPublished()) {
  91.             throw $this->createNotFoundException('Invalid request');
  92.         }
  93.         $this->view->Trenery $object;
  94.     }
  95. }