Completed
Push — master ( fec5e4...9d55fa )
by Vojta
01:20
created

Categories::listOverrideColumnValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php namespace VojtaSvoboda\Brands\Controllers;
2
3
use Backend;
4
use BackendMenu;
5
use Backend\Classes\Controller;
6
7
/**
8
 * Categories Back-end Controller
9
 */
10
class Categories extends Controller
11
{
12
    public $implement = [
13
        'Backend\Behaviors\FormController',
14
        'Backend\Behaviors\ListController',
15
        'Backend\Behaviors\ReorderController',
16
    ];
17
18
    public $formConfig = 'config_form.yaml';
19
    public $listConfig = 'config_list.yaml';
20
    public $reorderConfig = 'config_reorder.yaml';
21
22
    public $requiredPermissions = [
23
        'vojtasvoboda.brands.categories',
24
    ];
25
26
    public function __construct()
27
    {
28
        parent::__construct();
29
30
        BackendMenu::setContext('VojtaSvoboda.Brands', 'brands', 'categories');
31
    }
32
33
    public function listOverrideColumnValue($record, $columnName, $definition = null)
34
    {
35
        if ($columnName == 'brands_count') {
36
            $link = Backend::url('vojtasvoboda/brands/brands?category=' . $record->id);
37
38
            return '<a class="btn btn-xs btn-primary" href="' . $link . '">' . $record->brands_count . '</a>';
39
        }
40
    }
41
}
42