<?php
namespace App\Controller;
use Pimcore\Cache;
use Pimcore\Model\DataObject\Webcam;
use Symfony\Component\HttpFoundation\Request;
class WebcamController extends AbstractController
{
public function overviewAction(Request $request)
{
$this->addResponseHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
$this->addResponseHeader('Pragma', 'no-cache');
$this->addResponseHeader('Expires', 0);
Cache::disable();
$webcams = new Webcam\Listing();
$webcams->addConditionParam('region__id != "" AND region__id IS NOT NULL');
$webcams->addConditionParam('(image != "" AND image IS NOT NULL) or (image_override != "" AND image_override IS NOT NULL)');
$webcams->setOrderKey('region__id ASC, RAND()', false);
// $webcams->setGroupBy('region__id');
return $this->renderTemplate('Webcam/overview.html.twig', [
'webcams' => $webcams
]);
}
public function detailAction(Request $request)
{
$this->addResponseHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
$this->addResponseHeader('Pragma', 'no-cache');
$this->addResponseHeader('Expires', 0);
Cache::disable();
$region = $this->document->getProperty('region');
$webcams = new Webcam\Listing();
$webcams->addConditionParam('(image != "" AND image IS NOT NULL) or (image_override != "" AND image_override IS NOT NULL)');
$webcams->addConditionParam('region__id = :id', ['id' => $region->getId()]);
$webcams->setOrderKey('FIELD(webcamType, "Panomax", "Feratel", "iFrame")', false);
return $this->renderTemplate('Webcam/detail.html.twig', [
'webcams' => $webcams
]);
}
}