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

fnagel / t3extblog / 32822688124

24 Aug 2026 09:50PM UTC coverage: 76.723% (-0.7%) from 77.401%
32822688124

push

github

fnagel
[FEATURE] Add limit setting to all list based dashboard widgets

https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.0/Feature-107036-ConfigurableDashboardWidgets.html
https://docs.typo3.org/c/typo3/cms-dashboard/14.3/en-us/Developer/ConfigurableWidgets.html

2 of 32 new or added lines in 2 files covered. (6.25%)

40 existing lines in 11 files now uncovered.

2650 of 3454 relevant lines covered (76.72%)

7.96 hits per line

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

94.64
/Classes/Service/BackendModuleService.php
1
<?php
2

3
namespace FelixNagel\T3extblog\Service;
4

5
/**
6
 * This file is part of the "t3extblog" Extension for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11

12
use FelixNagel\T3extblog\Utility\FrontendUtility;
13
use TYPO3\CMS\Backend\Template\Components\ComponentFactory;
14
use TYPO3\CMS\Core\Imaging\IconSize;
15
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
16
use TYPO3\CMS\Backend\Template\ModuleTemplate;
17
use TYPO3\CMS\Backend\Utility\BackendUtility;
18
use TYPO3\CMS\Core\Page\PageRenderer;
19
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20
use TYPO3\CMS\Core\Imaging\IconFactory;
21
use TYPO3\CMS\Core\Localization\LanguageService;
22
use TYPO3\CMS\Core\Type\Bitmask\Permission;
23
use TYPO3\CMS\Core\Utility\GeneralUtility;
24
use TYPO3\CMS\Extbase\Mvc\Request;
25
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder as MvcUriBuilder;
26
use TYPO3\CMS\Backend\Routing\UriBuilder as BackendUriBuilder;
27

28
/**
29
 * BackendModuleService.
30
 *
31
 * @SuppressWarnings("PHPMD.CouplingBetweenObjects")
32
 */
33
class BackendModuleService
34
{
35
    /**
36
     * BackendModuleService constructor.
37
     */
38
    public function __construct(
7✔
39
        protected ModuleTemplate $moduleTemplate,
40
        protected ComponentFactory $componentFactory,
41
        protected int $pid
42
    ) {
43
    }
7✔
44

45
    /**
46
     * Add doc header meta information
47
     */
48
    public function addMetaInformation()
7✔
49
    {
50
        $permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(Permission::PAGE_SHOW);
7✔
51
        $pageRecord = BackendUtility::readPageAccess($this->pid, $permissionClause);
7✔
52

53
        if ($pageRecord) {
7✔
54
            $this->moduleTemplate->getDocHeaderComponent()->setPageBreadcrumb($pageRecord);
7✔
55
        }
56
    }
57

58
    /**
59
     * Add JS and CSS assets to the view
60
     */
61
    public function addViewAssets(array $requireJsModules = [], array $cssLibraries = [])
7✔
62
    {
63
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
7✔
64

65
        foreach ($requireJsModules as $requireJsModule) {
7✔
66
            $pageRenderer->loadJavaScriptModule($requireJsModule);
7✔
67
        }
68

69
        foreach ($cssLibraries as $cssLibrary) {
7✔
70
            $pageRenderer->addCssLibrary($cssLibrary);
7✔
71
        }
72
    }
73

74
    /**
75
     * Generates the action menu
76
     *
77
     */
78
    public function addViewHeaderMenu(Request $request, array $menuItems, string $menuIdentifier)
7✔
79
    {
80
        $menu = $this->componentFactory->createMenu();
7✔
81
        $menu->setIdentifier($menuIdentifier);
7✔
82

83
        $uriBuilder = GeneralUtility::makeInstance(MvcUriBuilder::class);
7✔
84
        $uriBuilder->setRequest($request);
7✔
85

86
        foreach ($menuItems as $menuItemConfig) {
7✔
87
            $isActive = ($request->getControllerActionName() === $menuItemConfig['action'] &&
7✔
88
                $request->getControllerName() === $menuItemConfig['controller']);
7✔
89
            $menuItem = $this->componentFactory->createMenuItem()
7✔
90
                ->setTitle($menuItemConfig['label'])
7✔
91
                ->setHref($uriBuilder->reset()->uriFor($menuItemConfig['action'], [], $menuItemConfig['controller']))
7✔
92
                ->setActive($isActive);
7✔
93
            $menu->addMenuItem($menuItem);
7✔
94
        }
95

96
        $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
7✔
97
    }
98

99
    /**
100
     * Create the panel of buttons
101
     */
102
    public function addViewHeaderButtons(array $buttonItems, ?string $shortcutModuleName = null)
7✔
103
    {
104
        $uriBuilder = GeneralUtility::makeInstance(BackendUriBuilder::class);
7✔
105
        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
7✔
106
        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
7✔
107

108
        foreach ($buttonItems as $configuration) {
7✔
109
            $parameters = [
7✔
110
                'edit' => [
7✔
111
                    $configuration['table'] => [
7✔
112
                        $this->pid => 'new',
7✔
113
                    ],
7✔
114
                ],
7✔
115
                // @extensionScannerIgnoreLine
116
                'returnUrl' => FrontendUtility::getNormalizedParams()->getRequestUri(),
7✔
117
            ];
7✔
118
            if (!empty($configuration['defaults'])) {
7✔
UNCOV
119
                $parameters['defVals'] = $configuration['defaults'];
×
120
            }
121

122
            $viewButton = $this->componentFactory->createLinkButton()
7✔
123
                ->setHref((string)$uriBuilder->buildUriFromRoute('record_edit', $parameters))
7✔
124
                ->setTitle($configuration['label'])
7✔
125
                ->setIcon($iconFactory->getIcon($configuration['icon'], IconSize::SMALL, 'overlay-new'));
7✔
126

127
            $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
7✔
128
        }
129

130
        // Shortcut
131
        if ($shortcutModuleName !== null) {
7✔
132
            $shortcutButton = $this->componentFactory->createShortcutButton()
7✔
133
                ->setRouteIdentifier($shortcutModuleName)
7✔
134
                ->setDisplayName('Blog');
7✔
135
            $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
7✔
136
        }
137
    }
138

139

140
    protected function getLanguageService(): LanguageService
×
141
    {
UNCOV
142
        return $GLOBALS['LANG'];
×
143
    }
144

145

146
    protected function getBackendUserAuthentication(): BackendUserAuthentication
7✔
147
    {
148
        return $GLOBALS['BE_USER'];
7✔
149
    }
150
}
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