diff --git a/config/routing/1_static.yaml b/config/routing/1_static.yaml index 7ef1703d..6859e90f 100644 --- a/config/routing/1_static.yaml +++ b/config/routing/1_static.yaml @@ -3,18 +3,21 @@ privacy: defaults: _controller: App\Controller\TemplateController::staticAction templateName: privacy + title: 'Datenschutzerklärung' impress: path: /impress defaults: _controller: App\Controller\TemplateController::staticAction templateName: impress + title: 'Impressum' limits: path: /grenzwerte defaults: _controller: App\Controller\TemplateController::staticAction templateName: limits + title: 'Übersicht über Schadstoffe und Grenzwerte' pollutant_pm10: path: /schadstoffe/feinstaub diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index eea77dac..903901bf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -190,11 +190,6 @@ parameters: count: 1 path: src/Controller/TemplateController.php - - - message: "#^Ternary operator condition is always true\\.$#" - count: 1 - path: src/Controller/TemplateController.php - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectRepository\\\\:\\:findActiveStations\\(\\)\\.$#" count: 1 diff --git a/src/Controller/TemplateController.php b/src/Controller/TemplateController.php index a8a4f3c4..b34b7f3b 100644 --- a/src/Controller/TemplateController.php +++ b/src/Controller/TemplateController.php @@ -4,23 +4,12 @@ use App\Air\SeoPage\SeoPage; use App\Entity\City; -use Doctrine\Persistence\ManagerRegistry; -use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\RouterInterface; -use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface; use WhiteOctober\BreadcrumbsBundle\Model\Breadcrumbs; class TemplateController extends AbstractController { - public function __construct( - protected EntrypointLookupCollectionInterface $entrypointLookupCollection, - ManagerRegistry $managerRegistry - ) - { - parent::__construct($managerRegistry); - } - public function cityListAction(): Response { return $this->render( @@ -30,10 +19,8 @@ public function cityListAction(): Response ); } - public function staticAction(string $templateName, Breadcrumbs $breadcrumbs, RouterInterface $router, SeoPage $seoPage): Response + public function staticAction(string $templateName, string $title, Breadcrumbs $breadcrumbs, RouterInterface $router, SeoPage $seoPage): Response { - $title = $this->readH2Tag($templateName); - $templateFilename = sprintf('Static/%s.html.twig', $templateName); $seoPage->setTitle($title); @@ -44,19 +31,4 @@ public function staticAction(string $templateName, Breadcrumbs $breadcrumbs, Rou return $this->render($templateFilename); } - - protected function readH2Tag(string $templateName): ?string - { - $templateFilename = sprintf('Static/%s.html.twig', $templateName); - - $templateContent = $this->renderView($templateFilename); - - $crawler = new Crawler($templateContent); - $h2 = $crawler->filter('h2')->first(); - - /** @see https://github.com/symfony/webpack-encore-bundle/issues/73#issuecomment-514649426 */ - $this->entrypointLookupCollection->getEntrypointLookup()->reset(); - - return $h2 ? $h2->text() : null; - } }