src/Controller/WeatherController.php line 17

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace App\Controller;
  7. use Elements\Bundle\SeoHelperBundle\Service\PrettyUrl;
  8. use Pimcore\Model\DataObject\Weather;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. class WeatherController extends AbstractController
  12. {
  13.     public function weatherAction(Request $requestPrettyUrl $prettyUrl): Response
  14.     {
  15.         $listing = new Weather\Listing();
  16.         $editable $this->document->getEditable('weatherStations');
  17.         $stations $editable && !$editable->isEmpty() && method_exists($editable'getElements') ? $editable->getElements() : $listing->load();
  18.         $tabs array_map(function ($s) use ($stations$prettyUrl) {
  19.             return [
  20.                 'text' => $s->getName(),
  21.                 'id' => $s->getId(),
  22.                 'targetId' => 'tab-' $s->getId(),
  23.                 'isActive' => $s->getId() == $stations[0]->getId(),
  24.                 'contentUrl' => $prettyUrl->prettyUrl([ 'tab' => $s->getId() ], 'weather_tab'),
  25.             ];
  26.         }, $stations);
  27.         return $this->render('weather/weather.html.twig', [ 'tabs' => $tabs ]);
  28.     }
  29.     public function snowAction(Request $request): Response
  30.     {
  31.         return $this->render('weather/snow.html.twig');
  32.     }
  33. }