<?php
namespace App\Controller;
use Pimcore\Model\DataObject\News;
use Pimcore\Model\DataObject\Blog;
use Pimcore\Model\DataObject\Event;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ContentController extends BaseController
{
/**
* @Template
*
* @param Request $request
* @return array
*/
public function defaultAction(Request $request)
{
$document = \Pimcore\Model\Document::getByPath($request->getPathInfo());
$list = News::getByRelated_pages($document);
return $this->render('content/default.html.twig', [
'newslist' => $list
]);
// return [];
}
/**
* @return Response
*/
public function frontpageAction()
{
$newsList = new News\Listing();
$newsList->setOrderKey('publish_date');
$newsList->setOrder('DESC');
$newsList->setLimit(2);
$eventList = new Event\Listing();
$eventList->setOrderKey('from_time');
$eventList->setOrder('ASC');
$eventList->setLimit(3);
$eventList->setCondition("to_time > ?", [time()]);
$blogList = new Blog\Listing();
$blogList->setOrderKey('pubDate');
$blogList->setOrder('DESC');
$blogList->setLimit(2);
return $this->render('content/frontpage.html.twig', [
'hideBreadcrumbs' => true,
'news' => $newsList,
'events' => $eventList,
'blogs' => $blogList
]);
}
/**
* @Template
*
* @param Request $request
* @return array
*/
public function sectionAction(Request $request)
{
return $this->render('content/section.html.twig', [
'hideBreadcrumbs' => true
]);
}
/**
* @Template
*
* @param Request $request
* @return array
*/
public function sitemapAction(Request $request)
{
return $this->render('content/sitemap.html.twig', []);
}
/**
* @Template
*
* @param Request $request
* @return array
*/
public function designAction(Request $request)
{
return $this->render('designguide/design.html.twig', []);
}
/**
* @Template
*
* @param Request $request
* @return array
*/
public function trainingAction(Request $request)
{
$eventList = new Event\Listing();
$eventList->setOrderKey('from_time');
$eventList->setOrder('ASC');
$eventList->setLimit(2);
$eventList->setCondition("to_time > ?", [time()]);
$eventList->addConditionParam("is_training = ?", 1, "AND");
return $this->render('content/training.html.twig', [
'hideBreadcrumbs' => true,
'events' => $eventList,
]);
}
}