Completed
Push — master ( c18000...efec97 )
by Anton
12s
created

Grid   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 21 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
 * @package  Application\Users
17
 */
18
class Grid extends \Bluz\Grid\Grid
19
{
20
    /**
21
     * @var string
22
     */
23
    protected $uid = 'users';
24
25
    /**
26
     * init
27
     *
28
     * @return self
29
     */
30 1
    public function init()
31
    {
32
        // Create Select
33 1
        $select = new Select();
34 1
        $select->select('u.*, GROUP_CONCAT( ar.`name` SEPARATOR ", " ) AS rolesList')
35 1
            ->from('users', 'u')
36 1
            ->leftJoin('u', 'acl_users_roles', 'aur', 'u.`id` = aur.`userId`')
37 1
            ->leftJoin('aur', 'acl_roles', 'ar', 'ar.`id` = aur.`roleId`')
38 1
            ->groupBy('u.id');
39
40
41
        // Setup adapter
42 1
        $adapter = new SelectSource();
43 1
        $adapter->setSource($select);
44
45 1
        $this->setAdapter($adapter);
46 1
        $this->setDefaultLimit(25);
47 1
        $this->setAllowOrders(['login', 'email', 'status', 'id']);
48 1
        $this->setAllowFilters(['login', 'email', 'status', 'id', 'roleId']);
49 1
        return $this;
50
    }
51
}
52