Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f60880...61b949 )
by Sebastian
02:52
created

AbstractModule   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 30
dl 0
loc 111
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A printContent() 0 17 3
A __construct() 0 12 1
1
<?php
2
namespace Kitodo\Dlf\Common;
3
4
/**
5
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
6
 *
7
 * This file is part of the Kitodo and TYPO3 projects.
8
 *
9
 * @license GNU General Public License version 3 or later.
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 */
13
14
/**
15
 * Abstract module class for the 'dlf' extension
16
 *
17
 * @author Sebastian Meyer <[email protected]>
18
 * @package TYPO3
19
 * @subpackage dlf
20
 * @access public
21
 * @abstract
22
 */
23
abstract class AbstractModule extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
24
    public $extKey = 'dlf';
25
    public $prefixId = 'tx_dlf';
26
27
    /**
28
     * Holds the page record if access granted or FALSE if access denied
29
     *
30
     * @var mixed
31
     * @access protected
32
     */
33
    protected $pageInfo;
34
35
    /**
36
     * Holds the module's marker array
37
     *
38
     * @var array
39
     * @access protected
40
     */
41
    protected $markerArray = [];
42
43
    /**
44
     * Holds the PSR-7 response object
45
     *
46
     * @var \Psr\Http\Message\ResponseInterface
47
     * @access protected
48
     */
49
    protected $response;
50
51
    /**
52
     * Holds the module's subpart array
53
     *
54
     * @var array
55
     * @access protected
56
     */
57
    protected $subpartArray = [];
58
59
    /**
60
     * Holds the TYPO3_CONF_VARS array of this extension
61
     *
62
     * @var array
63
     * @access protected
64
     */
65
    protected $conf = [];
66
67
    /**
68
     * Holds the submitted form's data
69
     *
70
     * @var array
71
     * @access protected
72
     */
73
    protected $data;
74
75
    /**
76
     * Main function of the module.
77
     *
78
     * @access public
79
     *
80
     * @param \Psr\Http\Message\ServerRequestInterface $request: The request object
81
     * @param \Psr\Http\Message\ResponseInterface $response: The response object
82
     *
83
     * @abstract
84
     *
85
     * @return void
86
     */
87
    abstract public function main(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response);
88
89
    /**
90
     * Fills the response object with the module's output.
91
     *
92
     * @access protected
93
     *
94
     * @return void
95
     */
96
    protected function printContent() {
97
        // Add Javascript for function menu.
98
        $this->doc->JScode .= '<script type="text/javascript">script_ended = 0;function jumpToUrl(URL) { document.location = URL; }</script>';
99
        // Add Javascript for convenient module switch.
100
        $this->doc->postCode .= '<script type="text/javascript">script_ended = 1;</script>';
101
        // Render output.
102
        $this->content .= $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
103
        // Set defaults for menu.
104
        if (empty($this->markerArray['CSH'])) {
105
            $this->markerArray['CSH'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_'.$GLOBALS['MCONF']['name'], 'csh', $GLOBALS['BACK_PATH'], '', TRUE);
0 ignored issues
show
Unused Code introduced by
The call to TYPO3\CMS\Backend\Utilit...ckendUtility::cshItem() has too many arguments starting with TRUE. ( Ignorable by Annotation )

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

105
            /** @scrutinizer ignore-call */ 
106
            $this->markerArray['CSH'] = \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_'.$GLOBALS['MCONF']['name'], 'csh', $GLOBALS['BACK_PATH'], '', TRUE);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
106
        }
107
        if (empty($this->markerArray['MOD_MENU'])) {
108
            $this->markerArray['MOD_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
109
        }
110
        $this->content .= $this->doc->moduleBody($this->pageInfo, [], $this->markerArray, $this->subpartArray);
111
        $this->content .= $this->doc->endPage();
112
        $this->resonse->getBody()->write($this->content);
0 ignored issues
show
Bug introduced by
The property resonse does not exist on Kitodo\Dlf\Common\AbstractModule. Did you mean response?
Loading history...
113
    }
114
115
    /**
116
     * Initializes the backend module by setting internal variables, initializing the menu.
117
     *
118
     * @access public
119
     *
120
     * @return void
121
     */
122
    public function __construct() {
123
        $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
124
        $GLOBALS['LANG']->includeLLFile('EXT:'.$this->extKey.'/Resources/Private/Language/'.Helper::getUnqualifiedClassName(get_class($this)).'.xml');
125
        parent::init();
126
        $this->conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
127
        $this->pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
128
        $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
129
        $this->doc->setModuleTemplate('EXT:'.$this->extKey.'/Resources/Private/Templates/'.Helper::getUnqualifiedClassName(get_class($this)).'.tmpl');
130
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
131
        $this->doc->bodyTagAdditions = 'class="ext-'.$this->extKey.'-modules"';
132
        $this->doc->form = '<form action="" method="post" enctype="multipart/form-data">';
133
        $this->data = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($this->prefixId);
134
    }
135
}
136