RequisitesCombo::getPluginOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace hipanel\modules\finance\widgets\combo;
5
6
use hiqdev\combo\Combo;
7
use yii\web\JsExpression;
8
9
class RequisitesCombo extends Combo
10
{
11
    /** {@inheritdoc} */
12
    public $type = 'finance/requisite';
13
14
    /** {@inheritdoc} */
15
    public $name = 'name';
16
17
    /** {@inheritdoc} */
18
    public $url = '/finance/requisite/index';
19
20
    /** {@inheritdoc} */
21
    public $_return = ['id', 'name', 'email'];
22
23
    /** {@inheritdoc} */
24
    public $_rename = ['text' => 'name'];
25
26
    public $_primaryFilter = 'name_ilike';
27
28 View Code Duplication
    public function getPluginOptions($options = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        return parent::getPluginOptions([
31
            'select2Options' => [
32
                'templateResult' => new JsExpression("function (data) {
33
                    if (data.loading) {
34
                        return data.text;
35
                    }
36
37
                    return data.name + '<br>' + data.email;
38
                }"),
39
                'escapeMarkup' => new JsExpression('function (markup) {
40
                    return markup; // Allows HTML
41
                }'),
42
            ],
43
        ]);
44
    }
45
46
    /** {@inheritdoc} */
47
    public function getFilter()
48
    {
49
        return \hipanel\helpers\ArrayHelper::merge(parent::getFilter(), [
50
            'client' => 'client/client',
51
        ]);
52
    }
53
}
54