<?php
/**
* Created by Elements.at New Media Solutions GmbH
*
*/
namespace App\Controller;
use Elements\Bundle\SeoHelperBundle\Service\PrettyUrl;
use Pimcore\Model\DataObject\Weather;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class WeatherController extends AbstractController
{
public function weatherAction(Request $request, PrettyUrl $prettyUrl): Response
{
$listing = new Weather\Listing();
$editable = $this->document->getEditable('weatherStations');
$stations = $editable && !$editable->isEmpty() && method_exists($editable, 'getElements') ? $editable->getElements() : $listing->load();
$tabs = array_map(function ($s) use ($stations, $prettyUrl) {
return [
'text' => $s->getName(),
'id' => $s->getId(),
'targetId' => 'tab-' . $s->getId(),
'isActive' => $s->getId() == $stations[0]->getId(),
'contentUrl' => $prettyUrl->prettyUrl([ 'tab' => $s->getId() ], 'weather_tab'),
];
}, $stations);
return $this->render('weather/weather.html.twig', [ 'tabs' => $tabs ]);
}
public function snowAction(Request $request): Response
{
return $this->render('weather/snow.html.twig');
}
}