Completed
Push — master ( 19fed6...e690ae )
by
unknown
14:30
created

BackendUserGroupRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createQuery() 0 5 1
A findByUidList() 0 13 3
1
<?php
2
namespace TYPO3\CMS\Beuser\Domain\Repository;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * Repository for \TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup
19
 * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
20
 */
21
class BackendUserGroupRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
22
{
23
    /**
24
     * @var array Default order is by title ascending
25
     */
26
    protected $defaultOrderings = [
27
        'title' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
28
    ];
29
30
    /**
31
     * Overwrite createQuery to don't respect enable fields
32
     *
33
     * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
34
     */
35
    public function createQuery()
36
    {
37
        $query = parent::createQuery();
38
        $query->getQuerySettings()->setIgnoreEnableFields(true);
39
        return $query;
40
    }
41
42
    /**
43
     * Finds Backend Usergroups on a given list of uids
44
     *
45
     * @param array $uidList
46
     * @return array
47
     */
48
    public function findByUidList(array $uidList): array
49
    {
50
        $items = [];
51
52
        foreach ($uidList as $id) {
53
            $query = $this->createQuery();
54
            $query->matching($query->equals('uid', $id));
55
            $result = $query->execute(true);
56
            if ($result) {
57
                $items[] = $result[0];
58
            }
59
        }
60
        return $items;
61
    }
62
}
63