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
Pull Request — dev-extbase-fluid (#746)
by Alexander
03:26
created

AbstractController   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 32
c 2
b 0
f 0
dl 0
loc 97
rs 10
wmc 16

3 Methods

Rating   Name   Duplication   Size   Complexity  
A injectDocumentRepository() 0 3 1
A getLanguageService() 0 3 1
C loadDocument() 0 47 14
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\Doc;
15
use Kitodo\Dlf\Common\Helper;
16
use Kitodo\Dlf\Domain\Model\Document;
17
use Kitodo\Dlf\Domain\Repository\DocumentRepository;
18
use Psr\Log\LoggerAwareInterface;
19
use Psr\Log\LoggerAwareTrait;
20
use TYPO3\CMS\Core\Database\ConnectionPool;
21
use TYPO3\CMS\Core\Localization\LanguageService;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
use TYPO3\CMS\Core\Utility\MathUtility;
24
25
26
/**
27
 *
28
 */
29
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController implements LoggerAwareInterface
30
{
31
    use LoggerAwareTrait;
32
33
    /**
34
     * @var DocumentRepository
35
     */
36
    protected $documentRepository;
37
38
    /**
39
     * @param DocumentRepository $documentRepository
40
     */
41
    public function injectDocumentRepository(DocumentRepository $documentRepository)
42
    {
43
        $this->documentRepository = $documentRepository;
44
    }
45
46
    /**
47
     * @var
48
     */
49
    protected $extConf;
50
51
    /**
52
     * This holds the current document
53
     *
54
     * @var \Kitodo\Dlf\Domain\Model\Document
55
     * @access protected
56
     */
57
    protected $document;
58
59
    /**
60
     * Loads the current document into $this->doc
61
     *
62
     * @access protected
63
     *
64
     * @param array $requestData: The request data
65
     *
66
     * @return void
67
     */
68
    protected function loadDocument($requestData)
69
    {
70
        // Try to get document format from database
71
        if (!empty($requestData['id'])) {
72
73
            if (MathUtility::canBeInterpretedAsInteger($requestData['id'])) {
74
                // find document from repository by uid
75
                $this->document = $this->documentRepository->findByUid((int) $requestData['id']);
76
                if ($this->document) {
77
                    $doc = Doc::getInstance($this->document->getLocation(), $this->settings, true);
78
                }
79
            } else if (GeneralUtility::isValidUrl($requestData['id'])) {
80
81
                $doc = Doc::getInstance($requestData['id'], $this->settings, true);
82
83
                if ($doc->recordId) {
84
                    $this->document = $this->documentRepository->findOneByRecordId($doc->recordId);
0 ignored issues
show
Bug introduced by
The method findOneByRecordId() does not exist on Kitodo\Dlf\Domain\Repository\DocumentRepository. 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

84
                    /** @scrutinizer ignore-call */ 
85
                    $this->document = $this->documentRepository->findOneByRecordId($doc->recordId);
Loading history...
85
                }
86
87
                if ($this->document === null) {
88
                    // create new dummy Document object
89
                    $this->document = $this->objectManager->get(Document::class);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

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

89
                    $this->document = /** @scrutinizer ignore-deprecated */ $this->objectManager->get(Document::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
90
                }
91
92
                if ($this->document) {
93
                    $this->document->setLocation($requestData['id']);
94
                }
95
            }
96
97
            if ($this->document !== null && $doc !== null) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $doc does not seem to be defined for all execution paths leading up to this point.
Loading history...
98
                $this->document->setDoc($doc);
99
            }
100
101
        } elseif (!empty($requestData['recordId'])) {
102
103
            $this->document = $this->documentRepository->findOneByRecordId($requestData['recordId']);
104
105
            if ($this->document !== null) {
106
                $doc = Doc::getInstance($this->document->getLocation(), $this->settings, true);
0 ignored issues
show
Bug introduced by
The method getLocation() does not exist on TYPO3\CMS\Extbase\Persistence\QueryResultInterface. ( Ignorable by Annotation )

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

106
                $doc = Doc::getInstance($this->document->/** @scrutinizer ignore-call */ getLocation(), $this->settings, true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
107
                if ($this->document !== null && $doc !== null) {
108
                    $this->document->setDoc($doc);
0 ignored issues
show
Bug introduced by
The method setDoc() does not exist on TYPO3\CMS\Extbase\Persistence\QueryResultInterface. ( Ignorable by Annotation )

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

108
                    $this->document->/** @scrutinizer ignore-call */ 
109
                                     setDoc($doc);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
                } else {
110
                    $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"');
111
                }
112
            }
113
        } else {
114
            $this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading');
115
        }
116
    }
117
118
    /**
119
     * Returns the LanguageService
120
     *
121
     * @return LanguageService
122
     */
123
    protected function getLanguageService(): LanguageService
124
    {
125
        return $GLOBALS['LANG'];
126
    }
127
128
}
129