• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-badges / 12914111128

22 Jan 2025 05:52PM UTC coverage: 96.122% (-2.8%) from 98.95%
12914111128

push

github

web-flow
Merge pull request #873 from eliashaeussler/feature/maintenance-page

[FEATURE] Add maintenance page for homepage during downtimes

0 of 14 new or added lines in 1 file covered. (0.0%)

471 of 490 relevant lines covered (96.12%)

7.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/EventListener/ExceptionListener.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Symfony project "eliashaeussler/typo3-badges".
7
 *
8
 * Copyright (C) 2021-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace App\EventListener;
25

26
use App\Badge\Provider\BadgeProviderFactory;
27
use Symfony\Component\HttpFoundation\Response;
28
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
29
use Twig\Environment;
30

31
/**
32
 * ExceptionListener.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final readonly class ExceptionListener
38
{
NEW
39
    public function __construct(
×
40
        private BadgeProviderFactory $badgeProviderFactory,
41
        private Environment $twig,
NEW
42
    ) {}
×
43

NEW
44
    public function __invoke(ExceptionEvent $event): void
×
45
    {
NEW
46
        $route = $event->getRequest()->get('_route');
×
47

NEW
48
        if ('app_homepage' === $route) {
×
NEW
49
            $response = $this->renderResponse();
×
50

NEW
51
            $event->setResponse($response);
×
NEW
52
            $event->stopPropagation();
×
53
        }
54
    }
55

NEW
56
    private function renderResponse(): Response
×
57
    {
NEW
58
        return new Response(
×
NEW
59
            $this->twig->render('maintenance.html.twig', [
×
NEW
60
                'providers' => $this->badgeProviderFactory->getAll(),
×
NEW
61
            ]),
×
NEW
62
        );
×
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc