Completed
Pull Request — master (#247)
by
unknown
09:38
created

Grid   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
rs 10
ccs 15
cts 15
cp 1
wmc 1
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 22 1
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
/**
8
 * @namespace
9
 */
10
namespace Application\Users;
11
12
use Bluz\Db\Query\Select;
13
use Bluz\Grid\Source\SelectSource;
14
15
/**
16
 * @category Application
17
 * @package  Users
18
 */
19
class Grid extends \Bluz\Grid\Grid
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $uid = 'users';
25
26
    /**
27
     * init
28
     *
29
     * @return self
30
     */
31 1
    public function init()
32
    {
33
        // Create Select
34 1
        $select = new Select();
35 1
        $select->select('u.*, u.id as uid, GROUP_CONCAT( ar.`name` SEPARATOR ", " ) AS rolesList')
36 1
            ->from('users', 'u')
37 1
            ->leftJoin('u', 'acl_users_roles', 'aur', 'u.`id` = aur.`userId`')
38 1
            ->leftJoin('aur', 'acl_roles', 'ar', 'ar.`id` = aur.`roleId`')
39 1
            ->groupBy('u.id');
40
41
42
        // Setup adapter
43 1
        $adapter = new SelectSource();
44 1
        $adapter->setSource($select);
45
46 1
        $this->setAdapter($adapter);
47 1
        $this->setDefaultLimit(25);
48 1
        $this->addAlias('id', 'u.id');
49 1
        $this->setAllowOrders(['login', 'email', 'status', 'id']);
50 1
        $this->setAllowFilters(['login', 'email', 'status', 'id', 'roleId']);
51 1
        return $this;
52
    }
53
}
54