|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace hipanel\modules\server\controllers; |
|
4
|
|
|
|
|
5
|
|
|
use hipanel\base\CrudController; |
|
6
|
|
|
use hipanel\modules\server\cart\ServerOrderProduct; |
|
7
|
|
|
use hipanel\modules\server\cart\Tariff; |
|
8
|
|
|
use hipanel\modules\server\helpers\ServerHelper; |
|
9
|
|
|
use hiqdev\yii2\cart\actions\AddToCartAction; |
|
10
|
|
|
use Yii; |
|
11
|
|
|
|
|
12
|
|
|
class OrderController extends CrudController |
|
13
|
|
|
{ |
|
14
|
|
|
public function actions() |
|
15
|
|
|
{ |
|
16
|
|
|
return [ |
|
17
|
|
|
'add-to-cart' => [ |
|
18
|
|
|
'class' => AddToCartAction::class, |
|
19
|
|
|
'productClass' => ServerOrderProduct::class |
|
20
|
|
|
] |
|
21
|
|
|
]; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function actionOrder($id) |
|
25
|
|
|
{ |
|
26
|
|
|
$package = ServerHelper::getAvailablePackages(null, $id); |
|
27
|
|
|
$osImages = ServerHelper::getOsimages($package->tariff->type); |
|
28
|
|
|
|
|
29
|
|
|
return $this->render('order', [ |
|
30
|
|
|
'package' => $package, |
|
31
|
|
|
'product' => new ServerOrderProduct(['tariff_id' => $package->tariff->id]), |
|
32
|
|
|
'groupedOsimages' => ServerHelper::groupOsimages($osImages), |
|
|
|
|
|
|
33
|
|
|
'panels' => ServerHelper::getPanels(), |
|
34
|
|
|
]); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function actionIndex() |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->actionXenSsd(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
View Code Duplication |
public function actionXenSsd() |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
|
return $this->render('xen_ssd', [ |
|
45
|
|
|
'packages' => ServerHelper::getAvailablePackages(Tariff::TYPE_XEN), |
|
46
|
|
|
'tariffTypes' => Yii::$app->params['vdsproduct'], |
|
47
|
|
|
]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
View Code Duplication |
public function actionOpenVz() |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
return $this->render('xen_ssd', [ |
|
53
|
|
|
'packages' => ServerHelper::getAvailablePackages(Tariff::TYPE_OPENVZ), |
|
54
|
|
|
'tariffTypes' => Yii::$app->params['vdsproduct'], |
|
55
|
|
|
]); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function actionTariffsDetails() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->render('tariffs_details'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function actionAdvantages() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->render('advantages'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function actionWhatIsVds() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->render('what_is_vds'); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.