LinkSorter::renderSortLinks()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
ccs 0
cts 17
cp 0
rs 9.6666
cc 3
nc 4
nop 0
crap 12
1
<?php
2
/**
3
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\widgets;
12
13
class LinkSorter extends \yii\widgets\LinkSorter
14
{
15
    /**
16
     * @var boolean whether to show sorter button
17
     */
18
    public $show = false;
19
20
    public $uiModel;
21
22
    /**
23
     * @var string CSS classes, that will be applied to the container
24
     */
25
    public $containerClass = 'dropdown';
26
27
    /**
28
     * @var string CSS classes, that will be applied to the button
29
     */
30
    public $buttonClass = 'btn btn-sm btn-default dropdown-toggle';
31
32
    public $options = ['class' => 'dropdown-menu', 'role' => 'menu', 'aria-labelledby' => ''];
33
34
    public $dataProvider;
35
36
    public function run()
37
    {
38
        if ($this->show) {
39
            parent::run();
40
        }
41
    }
42
43
    /**
44
     * Renders the sort links.
45
     *
46
     * @return string the rendering result
47
     */
48
    protected function renderSortLinks()
49
    {
50
        $attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes;
51
        $links      = [];
52
        foreach ($attributes as $name) {
53
            $links[] = $this->sort->link($name);
54
        }
55
56
        return $this->render('LinkSorterView', [
57
            'id'             => $this->id,
58
            'links'          => $links,
59
            'attributes'     => $this->sort->attributes,
60
            'options'        => array_merge($this->options, ['encode' => false]),
61
            'containerClass' => $this->containerClass,
62
            'buttonClass'    => $this->buttonClass,
63
            'uiModel'        => $this->uiModel,
64
        ]);
65
    }
66
}
67