<?php
namespace AppBundle\Controller;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\DataObject\Akcii;
use Pimcore\Model\DataObject\Budni;
use Pimcore\Model\DataObject\Trenery;
use Symfony\Component\HttpFoundation\Request;
use Zend\Paginator\Paginator;
class NewsController extends FrontendController
{
// КОНТРОЛЕР АКЦИЙ
public function akciiAction(Request $request)
{
$actionsList = new Akcii\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'akcii-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$actionsList->setCondition($where_str);
$actionsList->setOrderKey('dateSort');
$paginator = new Paginator($actionsList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(8);
$this->view->listCount = $actionsList->count();
$this->view->paginator = $paginator;
}
public function showAkciiAction(Request $request)
{
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Akcii::getByPath($docPath);
if (!$object instanceof Akcii || !$object->isPublished()) {
// this will trigger a 404 error response
throw $this->createNotFoundException('Invalid request');
}
$this->view->Akcii = $object;
}
// КОНТРОЛЕР БУДНЕЙ
public function budniAction(Request $request)
{
// get a list of news objects and order them by date
$budniList = new Budni\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'budni-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$budniList->setCondition($where_str);
$budniList->setOrderKey('dateSort');
$budniList->setOrder('desc');
$paginator = new Paginator($budniList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(9);
$this->view->listCount = $budniList->count();
$this->view->paginator = $paginator;
}
public function showBudniAction(Request $request)
{
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Budni::getByPath($docPath);
if (!$object instanceof Budni || !$object->isPublished()) {
// this will trigger a 404 error response
throw $this->createNotFoundException('Invalid request');
}
$this->view->Budni = $object;
}
// КОНТРОЛЕР ТРЕНЕРОВ
public function treneryAction(Request $request)
{
$treneryList = new Trenery\Listing();
$val = 'cross';
if(strstr($request->getRequestUri(), 'komanda-fitness-energy')) {
$val = 'fitness';
}
$where_str = "branch LIKE '%$val%' or branch LIKE 'all'";
$treneryList->setCondition($where_str);
$treneryList->setOrderKey('dateSort');
$paginator = new Paginator($treneryList);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(40);
$this->view->listCount = $treneryList->count();
$this->view->paginator = $paginator;
}
public function showTreneryAction(Request $request) {
$docPath = $request->getPathInfo();
// "id" is the named parameters in "Static Routes"
$object = Trenery::getByPath($docPath);
if (!$object instanceof Trenery || !$object->isPublished()) {
throw $this->createNotFoundException('Invalid request');
}
$this->view->Trenery = $object;
}
}