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.
Completed
Push — dev-extbase-fluid ( 5837d7...fc9799 )
by Alexander
02:57 queued 02:54
created

NewTenantController::initializeAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
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
namespace Kitodo\Dlf\Controller;
13
14
use Kitodo\Dlf\Common\Helper;
15
use TYPO3\CMS\Backend\Utility\BackendUtility;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Utility\BackendUtility was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17
use TYPO3\CMS\Core\Localization\LanguageService;
18
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
19
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
20
use Kitodo\Dlf\Domain\Repository\StructureRepository;
21
use Kitodo\Dlf\Domain\Repository\MetadataRepository;
22
use Kitodo\Dlf\Domain\Repository\SolrCoreRepository;
23
24
class NewTenantController extends AbstractController
25
{
26
    /**
27
     * @var int
28
     */
29
    protected $pid;
30
31
    /**
32
     * @var array
33
     */
34
    protected $pageInfo;
35
36
    /**
37
     * Backend Template Container
38
     *
39
     * @var string
40
     */
41
    protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\View\BackendTemplateView was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
43
    /**
44
     * @var StructureRepository
45
     */
46
    protected $structureRepository;
47
48
    /**
49
     * @param StructureRepository $structureRepository
50
     */
51
    public function injectStructureRepository(StructureRepository $structureRepository)
52
    {
53
        $this->structureRepository = $structureRepository;
54
    }
55
56
    /**
57
     * @var MetadataRepository
58
     */
59
    protected $metadataRepository;
60
61
    /**
62
     * @param MetadataRepository $metadataRepository
63
     */
64
    public function injectMetadataRepository(MetadataRepository $metadataRepository)
65
    {
66
        $this->metadataRepository = $metadataRepository;
67
    }
68
69
    /**
70
     * @var SolrCoreRepository
71
     */
72
    protected $solrCoreRepository;
73
74
    /**
75
     * @param SolrCoreRepository $solrCoreRepository
76
     */
77
    public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository)
78
    {
79
        $this->solrCoreRepository = $solrCoreRepository;
80
    }
81
82
    /**
83
     * Initialization for all actions
84
     *
85
     */
86
    protected function initializeAction()
87
    {
88
        // Load backend localization file.
89
        $this->getLanguageService()->includeLLFile('EXT:dlf/Resources/Private/Language/locallang_be.xlf');
90
        $this->getLanguageService()->includeLLFile('EXT:dlf/Resources/Private/Language/locallang_mod_newtenant.xlf');
91
    }
92
93
    /**
94
     * Action adding metadata records
95
     */
96
    public function addMetadataAction()
97
    {
98
        // Include metadata definition file.
99
        $metadataDefaults = include (ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php');
100
        $i = 0;
101
        // Build data array.
102
        $this->pid = (int) GeneralUtility::_GP('id');
103
104
        foreach ($metadataDefaults as $index_name => $values) {
105
            $formatIds = [];
106
            foreach ($values['format'] as $format) {
107
                $formatIds[] = uniqid('NEW');
108
                $data['tx_dlf_metadataformat'][end($formatIds)] = $format;
109
                $data['tx_dlf_metadataformat'][end($formatIds)]['pid'] = intval($this->pid);
110
                $i++;
111
            }
112
            $data['tx_dlf_metadata'][uniqid('NEW')] = [
113
                'pid' => intval($this->pid),
114
                'label' => $this->getLanguageService()->getLL('metadata.' . $index_name),
115
                'index_name' => $index_name,
116
                'format' => implode(',', $formatIds),
117
                'default_value' => $values['default_value'],
118
                'wrap' => (!empty($values['wrap']) ? $values['wrap'] : $GLOBALS['TCA']['tx_dlf_metadata']['columns']['wrap']['config']['default']),
119
                'index_tokenized' => $values['index_tokenized'],
120
                'index_stored' => $values['index_stored'],
121
                'index_indexed' => $values['index_indexed'],
122
                'index_boost' => $values['index_boost'],
123
                'is_sortable' => $values['is_sortable'],
124
                'is_facet' => $values['is_facet'],
125
                'is_listed' => $values['is_listed'],
126
                'index_autocomplete' => $values['index_autocomplete'],
127
            ];
128
            $i++;
129
        }
130
        $_ids = Helper::processDBasAdmin($data, [], true);
131
        // Check for failed inserts.
132
        if (count($_ids) == $i) {
133
            // Fine.
134
            $this->addFlashMessage(
135
                $this->getLanguageService()->getLL('flash.metadataAddedMsg'),
136
                $this->getLanguageService()->getLL('flash.metadataAdded'),
137
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
138
            );
139
        } else {
140
            // Something went wrong.
141
            $this->addFlashMessage(
142
                $this->getLanguageService()->getLL('flash.metadataNotAddedMsg'),
143
                $this->getLanguageService()->getLL('flash.metadataNotAdded'),
144
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
145
            );
146
        }
147
148
        $this->forward('index');
149
    }
150
151
    /**
152
     * Action adding Solr core records
153
     */
154
    public function addSolrCoreAction()
155
    {
156
        $this->pid = (int) GeneralUtility::_GP('id');
157
        // Build data array.
158
        $data['tx_dlf_solrcores'][uniqid('NEW')] = [
159
            'pid' => intval($this->pid),
160
            'label' => $this->getLanguageService()->getLL('solrcore') . ' (PID ' . $this->pid . ')',
161
            'index_name' => '',
162
        ];
163
        $_ids = Helper::processDBasAdmin($data);
164
        // Check for failed inserts.
165
        if (count($_ids) == 1) {
166
            // Fine.
167
            $this->addFlashMessage(
168
                $this->getLanguageService()->getLL('flash.solrcoreAddedMsg'),
169
                $this->getLanguageService()->getLL('flash.solrcoreAdded'),
170
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
171
            );
172
        } else {
173
            // Something went wrong.
174
            $this->addFlashMessage(
175
                $this->getLanguageService()->getLL('flash.solrcoreNotAddedMsg'),
176
                $this->getLanguageService()->getLL('flash.solrcoreNotAdded'),
177
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
178
            );
179
        }
180
181
        $this->forward('index');
182
    }
183
184
    /**
185
     * Action adding structure records
186
     */
187
    public function addStructureAction()
188
    {
189
        $this->pid = (int) GeneralUtility::_GP('id');
190
        // Include structure definition file.
191
        $structureDefaults = include (ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php');
192
        // Build data array.
193
        foreach ($structureDefaults as $index_name => $values) {
194
            $data['tx_dlf_structures'][uniqid('NEW')] = [
195
                'pid' => intval($this->pid),
196
                'toplevel' => $values['toplevel'],
197
                'label' => $this->getLanguageService()->getLL('structure.' . $index_name),
198
                'index_name' => $index_name,
199
                'oai_name' => $values['oai_name'],
200
                'thumbnail' => 0,
201
            ];
202
        }
203
        $_ids = Helper::processDBasAdmin($data, [], true);
204
        // Check for failed inserts.
205
        if (count($_ids) == count($structureDefaults)) {
206
            // Fine.
207
            $this->addFlashMessage(
208
                $this->getLanguageService()->getLL('flash.structureAddedMsg'),
209
                $this->getLanguageService()->getLL('flash.structureAdded'),
210
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
211
            );
212
        } else {
213
            // Something went wrong.
214
            $this->addFlashMessage(
215
                $this->getLanguageService()->getLL('flash.structureNotAddedMsg'),
216
                $this->getLanguageService()->getLL('flash.structureNotAdded'),
217
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
218
            );
219
        }
220
221
        $this->forward('index');
222
    }
223
224
    /**
225
     * Set up the doc header properly here
226
     *
227
     * @param ViewInterface $view
228
     * @return void
229
     */
230
    protected function initializeView(ViewInterface $view)
231
    {
232
        /** @var BackendTemplateView $view */
233
        parent::initializeView($view);
234
        if ($this->actionMethodName == 'indexAction'
235
            || $this->actionMethodName == 'onlineAction'
236
            || $this->actionMethodName == 'compareAction') {
237
            $this->pid = (int) GeneralUtility::_GP('id');
238
            $this->pageInfo = BackendUtility::readPageAccess($this->pid, $GLOBALS['BE_USER']->getPagePermsClause(1));
239
            $view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
240
        }
241
        if ($view instanceof BackendTemplateView) {
0 ignored issues
show
Bug introduced by
The type Kitodo\Dlf\Controller\BackendTemplateView was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
242
            $view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
243
        }
244
    }
245
246
    /**
247
     * Main function of the module
248
     *
249
     * @access public
250
     *
251
     */
252
    public function indexAction()
253
    {
254
        $this->pid = (int) GeneralUtility::_GP('id');
255
256
        if ($this->pageInfo['doktype'] != 254) {
257
            $this->addFlashMessage(
258
                $this->getLanguageService()->getLL('flash.wrongPageTypeMsg'),
259
                $this->getLanguageService()->getLL('flash.wrongPageType'),
260
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
261
            );
262
            return;
263
        }
264
265
        $structures = $this->structureRepository->findByPid($this->pid);
0 ignored issues
show
Bug introduced by
The method findByPid() does not exist on Kitodo\Dlf\Domain\Repository\StructureRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

265
        /** @scrutinizer ignore-call */ 
266
        $structures = $this->structureRepository->findByPid($this->pid);
Loading history...
266
267
        if ($structures) {
268
            // Fine.
269
            $this->addFlashMessage(
270
                $this->getLanguageService()->getLL('flash.structureOkayMsg'),
271
                $this->getLanguageService()->getLL('flash.structureOkay'),
272
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
273
            );
274
        } else {
275
            // Configuration missing.
276
            $this->addFlashMessage(
277
                $this->getLanguageService()->getLL('flash.structureNotOkayMsg'),
278
                $this->getLanguageService()->getLL('flash.structureNotOkay'),
279
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
280
            );
281
            $this->view->assign('structure', 1);
282
        }
283
284
        $metadata = $this->metadataRepository->findByPid($this->pid);
0 ignored issues
show
Bug introduced by
The method findByPid() does not exist on Kitodo\Dlf\Domain\Repository\MetadataRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

284
        /** @scrutinizer ignore-call */ 
285
        $metadata = $this->metadataRepository->findByPid($this->pid);
Loading history...
285
286
        if ($metadata) {
287
            // Fine.
288
            $this->addFlashMessage(
289
                $this->getLanguageService()->getLL('flash.metadataOkayMsg'),
290
                $this->getLanguageService()->getLL('flash.metadataOkay'),
291
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
292
            );
293
        } else {
294
            // Configuration missing.
295
            $this->addFlashMessage(
296
                $this->getLanguageService()->getLL('flash.metadataNotOkayMsg'),
297
                $this->getLanguageService()->getLL('flash.metadataNotOkay'),
298
                \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
299
            );
300
            $this->view->assign('metadata', 1);
301
        }
302
303
        $solrCore = $this->solrCoreRepository->findByPid($this->pid);
0 ignored issues
show
Bug introduced by
The method findByPid() does not exist on Kitodo\Dlf\Domain\Repository\SolrCoreRepository. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

303
        /** @scrutinizer ignore-call */ 
304
        $solrCore = $this->solrCoreRepository->findByPid($this->pid);
Loading history...
304
305
        if ($solrCore) {
306
            // Fine.
307
            $this->addFlashMessage(
308
                $this->getLanguageService()->getLL('flash.solrcoreOkayMsg'),
309
                $this->getLanguageService()->getLL('flash.solrcoreOkay'),
310
                \TYPO3\CMS\Core\Messaging\FlashMessage::OK
311
            );
312
        } else {
313
            // Solr core missing.
314
            $this->addFlashMessage(
315
                $this->getLanguageService()->getLL('flash.solrcoreMissingMsg'),
316
                $this->getLanguageService()->getLL('flash.solrcoreMissing'),
317
                \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
318
            );
319
            $this->view->assign('solr', 1);
320
        }
321
    }
322
}
323