Test Setup Failed
Push — master ( c353f4...14921c )
by eXeCUT
12:13
created

DynaGrid   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 70
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 45 2
A getGridId() 0 3 1
A run() 0 9 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: execut
5
 * Date: 11/15/17
6
 * Time: 12:14 PM
7
 */
8
9
namespace execut\actions\widgets;
10
11
use execut\yii\jui\WidgetTrait;
12
use kartik\export\ExportMenu;
13
use yii\helpers\ArrayHelper;
14
use yii\helpers\Html;
15
use \kartik\dynagrid\DynaGrid as KartikDynaGrid;
16
17
class DynaGrid extends KartikDynaGrid
18
{
19
    use WidgetTrait;
20
    public $dataProvider = null;
21
    public $storage = KartikDynaGrid::TYPE_DB;
22
    public $filter = null;
23
24
    public function init()
25
    {
26
        $columns = $this->filter->getGridColumns();
27
        $fullExportMenu = ExportMenu::widget([
28
            'dataProvider' => $this->dataProvider,
29
            'columns' => $columns,
30
            'target' => ExportMenu::TARGET_BLANK,
31
            'batchSize' => 1000,
32
            'fontAwesome' => true,
33
            'asDropdown' => false,
34
            'dropdownOptions' => [
35
                'label' => '<i class="glyphicon glyphicon-export"></i> Full'
36
            ],
37
        ]);
38
39
        $this->columns = $columns;
40
41
        $this->gridOptions = ArrayHelper::merge([
42
            'class' => GridView::class,
43
            'responsive' => false,
44
            'responsiveWrap' => false,
45
            'rowOptions' => function ($row) {
46
                if (method_exists($row, 'getRowOptions')) {
47
                    return $row->getRowOptions();
48
                }
49
            },
50
            'panel' => false,
51
            'export' => [
52
                'fontAwesome' => true,
53
                'itemsAfter'=> [
54
                    '<li role="presentation" class="divider"></li>',
55
                    '<li class="dropdown-header">Export All Data</li>',
56
                    $fullExportMenu
57
                ]
58
            ],
59
            'toggleDataOptions' => [
60
                'maxCount' => 100000,
61
            ],
62
            'filterModel' => $this->filter,
63
//            'toolbar' => $this->getToolbarConfig(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
            'dataProvider' => $this->dataProvider,
65
        ], $this->gridOptions);
66
67
        parent::init(); // TODO: Change the autogenerated stub
68
    }
69
70
    public function getGridId() {
71
        return $this->id . '-grid';
72
    }
73
74
    /**
75
     * @inheritdoc
76
     */
77
    public function run()
78
    {
79
        $this->gridOptions['options']['id'] = $this->id;
80
81
        Html::addCssClass($this->options, $this->getDefaultCssClass());
82
        $this->_registerBundle();
83
84
        echo Html::tag('div', GridView::widget($this->gridOptions), $this->options);
85
    }
86
}