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:42
created

CollectionRepository::findAllByUids()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
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\Domain\Repository;
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\Persistence\QueryInterface;
19
20
class CollectionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
21
{
22
23
    public function getCollectionList(array $uids, $showUserDefined = 0)
24
    {
25
        $query = $this->createQuery();
26
27
        if (!empty($uids)) {
28
            $constraints = [];
29
            // selected collections
30
            foreach ($uids as $uid) {
31
                $constraints[] = $query->contains('uid', $uid);
32
            }
33
            $query->matching($query->logicalOr($constraints));
34
        }
35
36
        $query->matching($query->equals('fe_cruser_id', $showUserDefined));
37
38
        $query->setOrderings([
39
            'label' => QueryInterface::ORDER_ASCENDING
40
        ]);
41
42
    }
43
44
45
    /**
46
     * Finds all collections
47
     *
48
     * @param string $uids separated by comma
49
     *
50
     * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
51
     */
52
    public function findAllByUids($uids)
53
    {
54
        $query = $this->createQuery();
55
56
        $constraints = [];
57
        $constraints[] = $query->in('uid', $uids);
58
59
        if (count($constraints)) {
60
            $query->matching($query->logicalAnd($constraints));
61
        }
62
63
        return $query->execute();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->execute() also could return the type array<mixed,object> which is incompatible with the documented return type TYPO3\CMS\Extbase\Persistence\QueryResultInterface.
Loading history...
64
    }
65
66
    public function getCollectionForMetadata($pages)
67
    {
68
        // Get list of collections to show.
69
        $query = $this->createQuery();
70
71
        $query->matching($query->equals('pid', $pages));
72
73
        return $query->execute();
74
    }
75
76
    /**
77
     * Finds all collection for the given settings
78
     *
79
     * @param array $settings
80
     *
81
     * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
82
     */
83
    public function findCollectionsBySettings($settings = [])
84
    {
85
        $query = $this->createQuery();
86
87
        $constraints = [];
88
89
        if ($settings['collections']) {
90
            $constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['collections']));
91
        }
92
93
        if ($settings['index_name']) {
94
            $constraints[] = $query->in('index_name', $settings['index_name']);
95
        }
96
97
        // do not find user created collections (used by oai-pmh plugin)
98
        if (!$settings['show_userdefined']) {
99
            $constraints[] = $query->equals('fe_cruser_id', 0);
100
        }
101
102
        // do not find collections without oai_name set (used by oai-pmh plugin)
103
        if ($settings['hideEmptyOaiNames']) {
104
            $constraints[] = $query->logicalNot($query->equals('oai_name', ''));
105
        }
106
107
        if (count($constraints)) {
108
            $query->matching(
109
                $query->logicalAnd($constraints)
110
            );
111
        }
112
113
        // order by oai_name
114
        $query->setOrderings(
115
            array('oai_name' => QueryInterface::ORDER_ASCENDING)
116
        );
117
118
        return $query->execute();
119
    }
120
121
    public function getIndexNameForSolr($settings, $set)
122
    {
123
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
124
            ->getQueryBuilderForTable('tx_dlf_collections');
125
126
        $where = '';
127
        if (!$settings['show_userdefined']) {
128
            $where = $queryBuilder->expr()->eq('tx_dlf_collections.fe_cruser_id', 0);
129
        }
130
        // For SOLR we need the index_name of the collection,
131
        // For DB Query we need the UID of the collection
132
        $result = $queryBuilder
133
            ->select(
134
                'tx_dlf_collections.index_name AS index_name',
135
                'tx_dlf_collections.uid AS uid',
136
                'tx_dlf_collections.index_search as index_query'
137
            )
138
            ->from('tx_dlf_collections')
139
            ->where(
140
                $queryBuilder->expr()->eq('tx_dlf_collections.pid', intval($settings['pages'])),
141
                $queryBuilder->expr()->eq('tx_dlf_collections.oai_name',
142
                    $queryBuilder->expr()->literal($set)),
143
                $where,
144
                Helper::whereExpression('tx_dlf_collections')
145
            )
146
            ->setMaxResults(1)
147
            ->execute();
148
149
        return $result;
150
    }
151
152
}
153