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

tomasnorre / crawler / 43405165794

13 Nov 2026 09:55AM UTC coverage: 71.322% (+1.4%) from 69.891%
43405165794

push

github

web-flow
!!! [TASK] Remove TYPO3 13 Support (#1323)

9 of 42 new or added lines in 6 files covered. (21.43%)

1910 of 2678 relevant lines covered (71.32%)

3.27 hits per line

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

86.25
/Classes/Service/BackendModuleLinkService.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace AOE\Crawler\Service;
6

7
/*
8
 * (c) 2023-     Tomas Norre Mikkelsen <tomasnorre@gmail.com>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21
use AOE\Crawler\Controller\Backend\BackendModuleCrawlerProcessController;
22
use AOE\Crawler\Controller\Backend\Helper\UrlBuilder;
23
use Psr\Http\Message\UriInterface;
24
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
25
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
26
use TYPO3\CMS\Backend\Template\ModuleTemplate;
27
use TYPO3\CMS\Core\Imaging\IconFactory;
28
use TYPO3\CMS\Core\Imaging\IconSize;
29
use TYPO3\CMS\Core\Localization\LanguageService;
30

31
class BackendModuleLinkService
32
{
33
    public function __construct(
34
        private readonly IconFactory $iconFactory,
35
        private readonly ComponentFactory $componentFactory,
36
    ) {
37
    }
8 ✔
38

39
    /**
40
     * Returns a tag for the refresh icon
41
     *
42
     * @throws RouteNotFoundException
43
     */
44
    public function getRefreshLink(ModuleTemplate $moduleTemplate, int $pageUid): string
45
    {
46
        return $this->getLinkButton(
1 ✔
47
            $moduleTemplate,
1 ✔
48
            'actions-refresh',
1 ✔
49
            $this->getLanguageService()->sL('crawler.messages:labels.refresh'),
1 ✔
50
            UrlBuilder::getBackendModuleUrl(
1 ✔
51
                [
1 ✔
52
                    'SET[\'crawleraction\']' => 'crawleraction',
1 ✔
53
                    'id' => $pageUid,
1 ✔
54
                ],
1 ✔
55
                BackendModuleCrawlerProcessController::BACKEND_MODULE
1 ✔
56
            )
1 ✔
57
        );
1 ✔
58
    }
59

60
    public function getFlushLink(ModuleTemplate $moduleTemplate): string
61
    {
62
        return $this->getLinkButton(
×
63
            $moduleTemplate,
×
64
            'actions-bolt',
×
NEW
65
            $this->getLanguageService()->sL('crawler.messages:labels.process.flush'),
×
66
            UrlBuilder::getBackendModuleUrl(
×
67
                [
×
68
                    'action' => 'flushProcess',
×
69
                ],
×
70
                BackendModuleCrawlerProcessController::BACKEND_MODULE
×
71
            )
×
72
        );
×
73
    }
74

75
    /**
76
     * @throws RouteNotFoundException
77
     */
78
    public function getAddLink(
79
        ModuleTemplate $moduleTemplate,
80
        int $currentActiveProcesses,
81
        int $maxActiveProcesses,
82
        bool $isCrawlerEnabled
83
    ): string {
84
        if (!$isCrawlerEnabled || $currentActiveProcesses >= $maxActiveProcesses) {
2 ✔
85
            return '';
1 ✔
86
        }
87

88
        return $this->getLinkButton(
1 ✔
89
            $moduleTemplate,
1 ✔
90
            'actions-add',
1 ✔
91
            $this->getLanguageService()->sL('crawler.messages:labels.process.add'),
1 ✔
92
            UrlBuilder::getBackendModuleUrl(
1 ✔
93
                [
1 ✔
94
                    'action' => 'addProcess',
1 ✔
95
                ],
1 ✔
96
                BackendModuleCrawlerProcessController::BACKEND_MODULE
1 ✔
97
            )
1 ✔
98
        );
1 ✔
99
    }
100

101
    /**
102
     * @throws RouteNotFoundException
103
     */
104
    public function getModeLink(ModuleTemplate $moduleTemplate, string $mode): string
105
    {
106
        if ($mode !== 'detail' && $mode !== 'simple') {
3 ✔
107
            return '';
1 ✔
108
        }
109

110
        if ($mode === 'detail') {
2 ✔
111
            $label = $this->getLanguageService()->sL('crawler.messages:labels.show.running');
1 ✔
112
            $linkMode = 'simple';
1 ✔
113
        } else {
114
            $label = $this->getLanguageService()->sL('crawler.messages:labels.show.all');
1 ✔
115
            $linkMode = 'detail';
1 ✔
116
        }
117

118
        return $this->getLinkButton(
2 ✔
119
            $moduleTemplate,
2 ✔
120
            'actions-document-view',
2 ✔
121
            $label,
2 ✔
122
            UrlBuilder::getBackendModuleUrl(
2 ✔
123
                [
2 ✔
124
                    'processListMode' => $linkMode,
2 ✔
125
                ],
2 ✔
126
                BackendModuleCrawlerProcessController::BACKEND_MODULE
2 ✔
127
            )
2 ✔
128
        );
2 ✔
129
    }
130

131
    /**
132
     * Returns a link for the panel to enable or disable the crawler
133
     *
134
     * @throws RouteNotFoundException
135
     */
136
    public function getEnableDisableLink(ModuleTemplate $moduleTemplate, bool $isCrawlerEnabled): string
137
    {
138
        if ($isCrawlerEnabled) {
2 ✔
139
            $iconIdentifier = 'tx-crawler-stop';
1 ✔
140
            $label = $this->getLanguageService()->sL('crawler.messages:labels.disablecrawling');
1 ✔
141
            $action = 'stopCrawling';
1 ✔
142
        } else {
143
            $iconIdentifier = 'tx-crawler-start';
1 ✔
144
            $label = $this->getLanguageService()->sL('crawler.messages:labels.enablecrawling');
1 ✔
145
            $action = 'resumeCrawling';
1 ✔
146
        }
147

148
        return $this->getLinkButton(
2 ✔
149
            $moduleTemplate,
2 ✔
150
            $iconIdentifier,
2 ✔
151
            $label,
2 ✔
152
            UrlBuilder::getBackendModuleUrl(
2 ✔
153
                [
2 ✔
154
                    'action' => $action,
2 ✔
155
                ],
2 ✔
156
                BackendModuleCrawlerProcessController::BACKEND_MODULE
2 ✔
157
            )
2 ✔
158
        );
2 ✔
159
    }
160

161
    private function getLinkButton(
162
        ModuleTemplate $moduleTemplate,
163
        string $iconIdentifier,
164
        string $title,
165
        UriInterface $href
166
    ): string {
167
        $moduleTemplate->getDocHeaderComponent()->getButtonBar();
6 ✔
168
        return (string) $this->componentFactory->createLinkButton()
6 ✔
169
            ->setHref((string) $href)
6 ✔
170
            ->setIcon($this->iconFactory->getIcon($iconIdentifier, IconSize::SMALL))
6 ✔
171
            ->setTitle($title)
6 ✔
172
            ->setShowLabelText(true);
6 ✔
173
    }
174

175
    private function getLanguageService(): LanguageService
176
    {
177
        return $GLOBALS['LANG'];
6 ✔
178
    }
179
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc