Grid   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 1
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
declare(strict_types=1);
8
9
namespace Application\Media;
10
11
use Bluz\Grid\Source\SqlSource;
12
13
/**
14
 * Grid based on SQL
15
 *
16
 * @category Application
17
 * @package  Media
18
 */
19
class Grid extends \Bluz\Grid\Grid
20
{
21
    protected $uid = 'options';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function init() : void
27
    {
28
        // Array
29
        $adapter = new SqlSource();
30
        $adapter->setSource(
31
            '
32
             SELECT m.*, u.login
33
             FROM media m
34
             LEFT JOIN users u ON u.id = m.userId
35
             '
36
        );
37
38
        $this->setAdapter($adapter);
39
        $this->setDefaultLimit(25);
40
        $this->setAllowOrders(['id', 'login', 'title', 'type', 'created', 'deleted']);
41
        $this->setAllowFilters(['userId', 'title', 'file']);
42
    }
43
}
44