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

fnagel / t3extblog / 26153411758

20 May 2026 09:20AM UTC coverage: 49.822% (-0.3%) from 50.149%
26153411758

push

github

fnagel
[TASK] Remove TYPO3 v14.2 from testing

Fixes issue with v14.2.0 has security issues and improves test
performance.

1683 of 3378 relevant lines covered (49.82%)

4.43 hits per line

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

0.0
/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 TYPO3\CMS\Core\Imaging\IconSize;
13
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
14
use TYPO3\CMS\Backend\Template\ModuleTemplate;
15
use TYPO3\CMS\Backend\Utility\BackendUtility;
16
use TYPO3\CMS\Core\Page\PageRenderer;
17
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
18
use TYPO3\CMS\Core\Imaging\IconFactory;
19
use TYPO3\CMS\Core\Localization\LanguageService;
20
use TYPO3\CMS\Core\Type\Bitmask\Permission;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
use TYPO3\CMS\Extbase\Mvc\Request;
23
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder as MvcUriBuilder;
24
use TYPO3\CMS\Backend\Routing\UriBuilder as BackendUriBuilder;
25

26
/**
27
 * BackendModuleService.
28
 *
29
 * @SuppressWarnings("PHPMD.CouplingBetweenObjects")
30
 */
31
class BackendModuleService
32
{
33
    /**
34
     * BackendModuleService constructor.
35
     */
36
    public function __construct(protected ModuleTemplate $moduleTemplate, protected int $pid)
×
37
    {
38
    }
×
39

40
    /**
41
     * Add doc header meta information
42
     */
43
    public function addMetaInformation()
×
44
    {
45
        $permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(Permission::PAGE_SHOW);
×
46
        $pageRecord = BackendUtility::readPageAccess($this->pid, $permissionClause);
×
47

48
        if ($pageRecord) {
×
49
            $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pageRecord);
×
50
        }
51
    }
52

53
    /**
54
     * Add JS and CSS assets to the view
55
     */
56
    public function addViewAssets(array $requireJsModules = [], array $cssLibraries = [])
×
57
    {
58
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
×
59

60
        foreach ($requireJsModules as $requireJsModule) {
×
61
            $pageRenderer->loadJavaScriptModule($requireJsModule);
×
62
        }
63

64
        foreach ($cssLibraries as $cssLibrary) {
×
65
            $pageRenderer->addCssLibrary($cssLibrary);
×
66
        }
67
    }
68

69
    /**
70
     * Generates the action menu
71
     *
72
     */
73
    public function addViewHeaderMenu(Request $request, array $menuItems, string $menuIdentifier)
×
74
    {
75
        $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
×
76
        $menu->setIdentifier($menuIdentifier);
×
77

78
        $uriBuilder = GeneralUtility::makeInstance(MvcUriBuilder::class);
×
79
        $uriBuilder->setRequest($request);
×
80

81
        foreach ($menuItems as $menuItemConfig) {
×
82
            $isActive = ($request->getControllerActionName() === $menuItemConfig['action'] &&
×
83
                $request->getControllerName() === $menuItemConfig['controller']);
×
84
            $menuItem = $menu->makeMenuItem()
×
85
                ->setTitle($menuItemConfig['label'])
×
86
                ->setHref($uriBuilder->reset()->uriFor($menuItemConfig['action'], [], $menuItemConfig['controller']))
×
87
                ->setActive($isActive);
×
88
            $menu->addMenuItem($menuItem);
×
89
        }
90

91
        $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
×
92
    }
93

94
    /**
95
     * Create the panel of buttons
96
     */
97
    public function addViewHeaderButtons(array $buttonItems, ?string $shortcutModuleName = null)
×
98
    {
99
        $uriBuilder = GeneralUtility::makeInstance(BackendUriBuilder::class);
×
100
        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
×
101
        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
×
102

103
        foreach ($buttonItems as $configuration) {
×
104
            $parameters = [
×
105
                'edit' => [
×
106
                    $configuration['table'] => [
×
107
                        $this->pid => 'new',
×
108
                    ],
×
109
                ],
×
110
                'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
×
111
            ];
×
112
            if (!empty($configuration['defaults'])) {
×
113
                $parameters['defVals'] = $configuration['defaults'];
×
114
            }
115

116
            $viewButton = $buttonBar->makeLinkButton()
×
117
                ->setHref((string)$uriBuilder->buildUriFromRoute('record_edit', $parameters))
×
118
                ->setTitle($configuration['label'])
×
119
                ->setIcon($iconFactory->getIcon($configuration['icon'], IconSize::SMALL, 'overlay-new'));
×
120

121
            $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
×
122
        }
123

124
        // Shortcut
125
        if ($shortcutModuleName !== null) {
×
126
            $shortcutButton = $buttonBar->makeShortcutButton()
×
127
                ->setRouteIdentifier($shortcutModuleName)
×
128
                ->setDisplayName('Blog');
×
129
            $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
×
130
        }
131
    }
132

133

134
    protected function getLanguageService(): LanguageService
×
135
    {
136
        return $GLOBALS['LANG'];
×
137
    }
138

139

140
    protected function getBackendUserAuthentication(): BackendUserAuthentication
×
141
    {
142
        return $GLOBALS['BE_USER'];
×
143
    }
144
}
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