1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\widgets\combo; |
12
|
|
|
|
13
|
|
|
use hiqdev\combo\Combo; |
14
|
|
|
use yii\helpers\ArrayHelper; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Service. |
18
|
|
|
*/ |
19
|
|
View Code Duplication |
class ServiceCombo extends Combo |
|
|
|
|
20
|
|
|
{ |
21
|
|
|
/** {@inheritdoc} */ |
22
|
|
|
public $name = 'name'; |
23
|
|
|
|
24
|
|
|
/** {@inheritdoc} */ |
25
|
|
|
public $type = 'hosting/service'; |
26
|
|
|
|
27
|
|
|
/** {@inheritdoc} */ |
28
|
|
|
public $url = '/hosting/service/index'; |
29
|
|
|
|
30
|
|
|
/** {@inheritdoc} */ |
31
|
|
|
public $_return = ['id', 'client', 'client_id', 'server', 'server_id', 'seller', 'seller_id', 'soft']; |
32
|
|
|
|
33
|
|
|
/** {@inheritdoc} */ |
34
|
|
|
public $_rename = ['text' => 'name']; |
35
|
|
|
|
36
|
|
|
/** {@inheritdoc} */ |
37
|
|
|
public $_filter = [ |
38
|
|
|
'client' => 'client/client', |
39
|
|
|
'server' => 'server/server', |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string the soft type, used by [[getFilter]] to filter by the soft type |
44
|
|
|
* @see getFilter() |
45
|
|
|
*/ |
46
|
|
|
public $softType; |
47
|
|
|
|
48
|
|
|
public $_pluginOptions = [ |
49
|
|
|
'activeWhen' => [ |
50
|
|
|
'server/server', |
51
|
|
|
], |
52
|
|
|
'affects' => [ |
53
|
|
|
'client/seller' => 'seller', |
54
|
|
|
'client/client' => 'client', |
55
|
|
|
'server/server' => 'server', |
56
|
|
|
], |
57
|
|
|
]; |
58
|
|
|
|
59
|
|
|
/** {@inheritdoc} */ |
60
|
|
|
public function getFilter() |
61
|
|
|
{ |
62
|
|
|
return ArrayHelper::merge(parent::getFilter(), [ |
63
|
|
|
'soft_type' => ['format' => $this->softType], |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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.