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 (#754)
by Alexander
02:55
created

ItemsProcFunc::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Hooks;
14
15
use Kitodo\Dlf\Common\Helper;
16
use TYPO3\CMS\Core\Database\ConnectionPool;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
19
use TYPO3\CMS\Extbase\Object\ObjectManager;
20
21
/**
22
 * Helper for Flexform's custom "itemsProcFunc"
23
 *
24
 * @author Sebastian Meyer <[email protected]>
25
 * @package TYPO3
26
 * @subpackage dlf
27
 * @access public
28
 */
29
class ItemsProcFunc
30
{
31
    /**
32
     * @var int
33
     */
34
    protected $storagePid;
35
36
    /**
37
     * Helper to get flexform's items array for plugin "Toolbox"
38
     *
39
     * @access public
40
     *
41
     * @param array &$params: An array with parameters
42
     *
43
     * @return void
44
     */
45
    public function toolList(&$params)
46
    {
47
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) {
48
            $params['items'][] = [Helper::getLanguageService()->getLL($label), $class];
49
        }
50
    }
51
52
    /**
53
     * The constructor to access TypoScript configuration
54
     *
55
     * @access public
56
     *
57
     * @return void
58
     */
59
    public function __construct()
60
    {
61
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
62
        $configurationManager = $objectManager->get(ConfigurationManager::class);
63
        // we must get the storagePid from full TypoScript setup at this point.
64
        $fullTyposcriptSetup = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
65
        $this->storagePid = $fullTyposcriptSetup["plugin."]["tx_dlf."]["persistence."]["storagePid"];
66
    }
67
68
    /**
69
     * Helper to get flexform's items array for plugin "Search"
70
     *
71
     * @access public
72
     *
73
     * @param array &$params: An array with parameters
74
     */
75
    public function getFacetsList(array &$params): void
76
    {
77
        $this->generateList(
78
            $params,
79
            'label,index_name',
80
            'tx_dlf_metadata',
81
            'sorting',
82
            'is_facet=1'
83
        );
84
    }
85
86
    /**
87
     * Get list items from database
88
     *
89
     * @access protected
90
     *
91
     * @param array &$params: An array with parameters
92
     * @param string $fields: Comma-separated list of fields to fetch
93
     * @param string $table: Table name to fetch the items from
94
     * @param string $sorting: Field to sort items by (optionally appended by 'ASC' or 'DESC')
95
     * @param string $andWhere: Additional AND WHERE clause
96
     *
97
     * @return void
98
     */
99
    protected function generateList(&$params, $fields, $table, $sorting, $andWhere = '')
100
    {
101
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
102
            ->getQueryBuilderForTable($table);
103
104
        // Get $fields from $table on given pid.
105
        $result = $queryBuilder
106
            ->select(...explode(',', $fields))
107
            ->from($table)
108
            ->where(
109
                $queryBuilder->expr()->eq($table . '.pid', intval($this->storagePid)),
110
                $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]),
111
                $andWhere
112
            )
113
            ->orderBy($sorting)
114
            ->execute();
115
116
        while ($resArray = $result->fetch(\PDO::FETCH_NUM)) {
117
            if ($resArray) {
118
                $params['items'][] = $resArray;
119
            }
120
        }
121
    }
122
}
123