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

eliashaeussler / typo3-warming / 25168936300

30 Apr 2026 01:45PM UTC coverage: 94.003% (-0.06%) from 94.066%
25168936300

push

github

web-flow
[TASK] Update stylelint-copyright to v3.10.1

| datasource | package             | from   | to     |
| ---------- | ------------------- | ------ | ------ |
| npm        | stylelint-copyright | 3.10.0 | 3.10.1 |

1740 of 1851 relevant lines covered (94.0%)

13.01 hits per line

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

93.75
/Classes/Controller/CacheWarmupController.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "warming".
7
 *
8
 * Copyright (C) 2021-2026 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 2 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 EliasHaeussler\Typo3Warming\Controller;
25

26
use CuyZ\Valinor;
27
use EliasHaeussler\CacheWarmup;
28
use EliasHaeussler\SSE;
29
use EliasHaeussler\Typo3SitemapLocator;
30
use EliasHaeussler\Typo3Warming\Configuration;
31
use EliasHaeussler\Typo3Warming\Crawler;
32
use EliasHaeussler\Typo3Warming\Http;
33
use EliasHaeussler\Typo3Warming\Service;
34
use EliasHaeussler\Typo3Warming\ValueObject;
35
use GuzzleHttp\Exception\GuzzleException;
36
use Psr\Http\Message;
37
use Psr\Log;
38
use Symfony\Component\DependencyInjection;
39

40
/**
41
 * CacheWarmupController
42
 *
43
 * @author Elias Häußler <elias@haeussler.dev>
44
 * @license GPL-2.0-or-later
45
 */
46
#[DependencyInjection\Attribute\Autoconfigure(public: true)]
47
final readonly class CacheWarmupController
48
{
49
    public function __construct(
12✔
50
        private Configuration\Configuration $configuration,
51
        private Log\LoggerInterface $logger,
52
        private Valinor\Mapper\TreeMapper $mapper,
53
        private Http\Message\ResponseFactory $responseFactory,
54
        private Service\CacheWarmupService $warmupService,
55
    ) {}
12✔
56

57
    /**
58
     * @throws CacheWarmup\Exception\Exception
59
     * @throws GuzzleException
60
     * @throws SSE\Exception\StreamIsActive
61
     * @throws SSE\Exception\StreamIsClosed
62
     * @throws SSE\Exception\StreamIsInactive
63
     * @throws Typo3SitemapLocator\Exception\BaseUrlIsNotSupported
64
     * @throws Typo3SitemapLocator\Exception\SitemapIsMissing
65
     * @throws \JsonException
66
     */
67
    public function __invoke(Message\ServerRequestInterface $request): Message\ResponseInterface
12✔
68
    {
69
        // Ensure request was sent using the EventSource API performing an SSE request
70
        if (!SSE\Stream\SelfEmittingEventStream::canHandle($request)) {
12✔
71
            return $this->responseFactory->badRequest('Invalid request headers');
1✔
72
        }
73

74
        // Build warmup request object
75
        try {
76
            $warmupRequest = $this->mapper->map(ValueObject\Request\WarmupRequest::class, $request->getQueryParams());
11✔
77
        } catch (Valinor\Mapper\MappingError $error) {
1✔
78
            $messages = array_map(strval(...), $error->messages()->toArray());
1✔
79

80
            $this->logger->error(
1✔
81
                'Error during mapping of query parameters to warmup request object.',
1✔
82
                ['errors' => $messages],
1✔
83
            );
1✔
84

85
            return $this->responseFactory->badRequest('Invalid request parameters');
1✔
86
        }
87

88
        // Don't kill execution on connection abort by user
89
        ignore_user_abort(true);
10✔
90

91
        // Open event stream
92
        $eventStream = SSE\Stream\SelfEmittingEventStream::create($warmupRequest->getId());
10✔
93
        $eventStream->open();
10✔
94

95
        // Cancel streaming on connection abort by user
96
        if (connection_aborted() === 1) {
10✔
97
            $eventStream->close();
×
98

99
            return $this->responseFactory->ok();
×
100
        }
101

102
        // Apply event stream to crawler
103
        $crawler = $this->configuration->getCrawler();
10✔
104
        if ($crawler instanceof Crawler\StreamableCrawler) {
10✔
105
            $crawler->setStream($eventStream);
10✔
106
        }
107

108
        // Perform cache warmup
109
        $result = $this->warmupService->warmup(
10✔
110
            $warmupRequest->getSites(),
10✔
111
            $warmupRequest->getPages(),
10✔
112
            $warmupRequest->getConfiguration()->getLimit(),
10✔
113
            $warmupRequest->getConfiguration()->getStrategy(),
10✔
114
        );
10✔
115

116
        // Send final response
117
        $warmupFinishedEvent = new Http\Message\Event\WarmupFinishedEvent($warmupRequest, $result);
10✔
118
        $eventStream->sendEvent($warmupFinishedEvent);
10✔
119

120
        // Close event stream
121
        $eventStream->close();
10✔
122

123
        return $this->responseFactory->ok();
10✔
124
    }
125
}
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

© 2026 Coveralls, Inc