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 — master ( b735c6...dbf868 )
by Sebastian
24s queued 14s
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 Psr\Log\LoggerAwareInterface;
17
use Psr\Log\LoggerAwareTrait;
18
use TYPO3\CMS\Core\Database\ConnectionPool;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
21
use TYPO3\CMS\Extbase\Object\ObjectManager;
22
23
/**
24
 * Helper for Flexform's custom "itemsProcFunc"
25
 *
26
 * @author Sebastian Meyer <[email protected]>
27
 * @package TYPO3
28
 * @subpackage dlf
29
 * @access public
30
 */
31
class ItemsProcFunc implements LoggerAwareInterface
32
{
33
    use LoggerAwareTrait;
34
35
    /**
36
     * @var int
37
     */
38
    protected $storagePid;
39
40
    /**
41
     * Helper to get flexform's items array for plugin "Toolbox"
42
     *
43
     * @access public
44
     *
45
     * @param array &$params: An array with parameters
46
     *
47
     * @return void
48
     */
49
    public function toolList(&$params)
50
    {
51
        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/Classes/Plugin/Toolbox.php']['tools'] as $class => $label) {
52
            $params['items'][] = [Helper::getLanguageService()->sL($label), $class];
53
        }
54
    }
55
56
    /**
57
     * Extract typoscript configuration from site root of the plugin
58
     *
59
     * @access public
60
     *
61
     * @param $params
62
     *
63
     * @return void
64
     */
65
    public function getTyposcriptConfigFromPluginSiteRoot($params) {
66
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
67
        $pid = $params['flexParentDatabaseRow']['pid'];
68
        $rootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($pid);
69
        $siterootRow = [];
70
        foreach ($rootline as $_row) {
71
            if ($_row['is_siteroot'] == '1') {
72
                $siterootRow = $_row;
73
                break;
74
            }
75
        }
76
77
        try {
78
            $ts = $objectManager->get(\TYPO3\CMS\Core\TypoScript\TemplateService::class, [$siterootRow['uid']]);
79
            $ts->rootLine = $rootline;
80
            $ts->runThroughTemplates($rootline, 0);
81
            $ts->generateConfig();
82
        } catch (\Exception $e) {
83
            $this->logger->error($e->getMessage());
84
        }
85
86
        $typoscriptConfig = $ts->setup;
87
        $this->storagePid = $typoscriptConfig['plugin.']['tx_dlf.']['persistence.']['storagePid'];
88
89
    }
90
91
    /**
92
     * Helper to get flexform's items array for plugin "Search"
93
     *
94
     * @access public
95
     *
96
     * @param array &$params: An array with parameters
97
     *
98
     * @return void
99
     */
100
    public function extendedSearchList(&$params)
101
    {
102
        $this->generateList(
103
            $params,
104
            'label,index_name',
105
            'tx_dlf_metadata',
106
            'label',
107
            'index_indexed=1'
108
        );
109
    }
110
111
    /**
112
     * Helper to get flexform's items array for plugin "Search"
113
     *
114
     * @access public
115
     *
116
     * @param array &$params: An array with parameters
117
     */
118
    public function getFacetsList(array &$params): void
119
    {
120
        $this->generateList(
121
            $params,
122
            'label,index_name',
123
            'tx_dlf_metadata',
124
            'label',
125
            'is_facet=1'
126
        );
127
    }
128
129
    /**
130
     * Get list items from database
131
     *
132
     * @access protected
133
     *
134
     * @param array &$params: An array with parameters
135
     * @param string $fields: Comma-separated list of fields to fetch
136
     * @param string $table: Table name to fetch the items from
137
     * @param string $sorting: Field to sort items by (optionally appended by 'ASC' or 'DESC')
138
     * @param string $andWhere: Additional AND WHERE clause
139
     *
140
     * @return void
141
     */
142
    protected function generateList(&$params, $fields, $table, $sorting, $andWhere = '')
143
    {
144
        $this->getTyposcriptConfigFromPluginSiteRoot($params);
145
146
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
147
            ->getQueryBuilderForTable($table);
148
149
        // Get $fields from $table on given pid.
150
        $result = $queryBuilder
151
            ->select(...explode(',', $fields))
152
            ->from($table)
153
            ->where(
154
                $queryBuilder->expr()->eq($table . '.pid', intval($this->storagePid)),
155
                $queryBuilder->expr()->in($table . '.sys_language_uid', [-1, 0]),
156
                $andWhere
157
            )
158
            ->orderBy($sorting)
159
            ->execute();
160
161
        while ($resArray = $result->fetch(\PDO::FETCH_NUM)) {
162
            if ($resArray) {
163
                $params['items'][] = $resArray;
164
            }
165
        }
166
    }
167
}
168