DigitalAssetManagementController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 63
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeView() 0 7 1
A handleRequest() 0 25 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
/*
5
 * This file is part of the package typo3/cms-digital-asset-management.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE file that was distributed with this source code.
9
 */
10
11
namespace TYPO3\CMS\DigitalAssetManagement\Controller;
12
13
use Psr\Http\Message\ResponseInterface;
14
use Psr\Http\Message\ServerRequestInterface;
15
use TYPO3\CMS\Backend\Template\ModuleTemplate;
16
use TYPO3\CMS\Core\Context\Context;
17
use TYPO3\CMS\Core\Http\HtmlResponse;
18
use TYPO3\CMS\Core\Page\PageRenderer;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
use TYPO3\CMS\Fluid\View\StandaloneView;
21
22
/**
23
 * Backend controller: The "Digital Asset Management" module
24
 *
25
 * Optional replacement of filelist
26
 */
27
class DigitalAssetManagementController
28
{
29
    /**
30
     * @var ModuleTemplate
31
     */
32
    protected $moduleTemplate;
33
34
    /**
35
     * @var StandaloneView
36
     */
37
    protected $view;
38
39
    /**
40
     * Default constructor
41
     */
42
    public function __construct()
43
    {
44
        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
45
    }
46
47
    /**
48
     * @param string $templateName
49
     */
50
    protected function initializeView(string $templateName): void
51
    {
52
        $this->view = GeneralUtility::makeInstance(StandaloneView::class);
53
        $this->view->setTemplate($templateName);
54
        $this->view->setTemplateRootPaths(['EXT:digital_asset_management/Resources/Private/Templates']);
55
        $this->view->setPartialRootPaths(['EXT:digital_asset_management/Resources/Private/Partials']);
56
        $this->view->setLayoutRootPaths(['EXT:digital_asset_management/Resources/Private/Layouts']);
57
    }
58
59
    /**
60
     * Main entry method: Dispatch to other actions - those method names that end with "Action".
61
     *
62
     * @param ServerRequestInterface $request the current request
63
     * @return ResponseInterface the response with the content
64
     */
65
    public function handleRequest(ServerRequestInterface $request): ResponseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
    public function handleRequest(/** @scrutinizer ignore-unused */ ServerRequestInterface $request): ResponseInterface

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        $backendUser = GeneralUtility::makeInstance(Context::class)->getAspect('backend.user');
68
69
        /**
70
         * @var PageRenderer $pageRenderer
71
         */
72
        $pageRenderer = $this->moduleTemplate->getPageRenderer();
73
        $pageRenderer->loadRequireJsModule('TYPO3/CMS/DigitalAssetManagement/DigitalAssetManagementActions');
74
        $pageRenderer->addCssFile('EXT:backend/Resources/Public/Css/backend.css');
75
        $pageRenderer->addCssFile('EXT:digital_asset_management/Resources/Public/JavaScript/Library/filelist.css');
76
        $pageRenderer->addInlineLanguageLabelFile('EXT:digital_asset_management/Resources/Private/Language/locallang_mod.xlf');
77
        $pageRenderer->addInlineLanguageLabelFile('EXT:digital_asset_management/Resources/Private/Language/locallang_vue.xlf');
78
        $pageRenderer->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/locallang_core.xlf', 'file_upload');
79
        $pageRenderer->addInlineSettingArray('BackendUser', [
80
            'isAdmin' => $backendUser->isAdmin(),
81
            'username' => $backendUser->get('username'),
82
        ]);
83
        $this->initializeView('index');
84
        // Add shortcut button
85
        $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
86
        $myButton = $buttonBar->makeShortcutButton()->setModuleName('dam');
87
        $buttonBar->addButton($myButton);
88
        $this->moduleTemplate->setContent($this->view->render());
89
        return new HtmlResponse($this->moduleTemplate->renderContent());
90
    }
91
}
92