Categories   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A listOverrideColumnValue() 0 8 2
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