GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RemoveAllButton::init()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace app\backend\widgets;
4
5
use yii\base\InvalidParamException;
6
use yii\base\Widget;
7
use yii\helpers\Html;
8
use kartik\icons\Icon;
9
10
class RemoveAllButton extends Widget
11
{
12
    public $url;
13
    public $gridSelector;
14
    public $htmlOptions = [];
15
    public $modalSelector = '#delete-confirmation';
16
17
    public function init()
18
    {
19
        if (!isset($this->url, $this->gridSelector)) {
20
            throw new InvalidParamException('Attribute \'url\' or \'gridSelector\' is not set');
0 ignored issues
show
Deprecated Code introduced by
The class yii\base\InvalidParamException has been deprecated with message: since 2.0.14. Use [[InvalidArgumentException]] instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
21
        }
22
23
        if (!isset($this->htmlOptions['id'])) {
24
            $this->htmlOptions['id'] = 'deleteItems';
25
        }
26
        Html::addCssClass($this->htmlOptions, 'btn');
27
    }
28
29
    public function run()
30
    {
31
        $this->registerScript();
32
        return $this->renderButton();
33
    }
34
35
    protected function renderButton()
36
    {
37
        return Html::button(
38
            Icon::show('trash-o') . ' ' .
39
            \Yii::t('app', 'Delete selected'),
40
            $this->htmlOptions
41
        );
42
    }
43
44
    protected function registerScript()
45
    {
46
        $this->view->registerJs("
47
            jQuery('#{$this->htmlOptions['id']}').on('click', function() {
48
                var items =  $('{$this->gridSelector}').yiiGridView('getSelectedRows');
49
                if (items.length) {
50
                    jQuery('{$this->modalSelector}').attr('data-url', '{$this->url}').attr('data-items', items).modal('show');
51
                }
52
                return false;
53
            });
54
        ");
55
    }
56
}
57