|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Server module for HiPanel |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-server |
|
7
|
|
|
* @package hipanel-module-server |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\modules\server\cart; |
|
13
|
|
|
|
|
14
|
|
|
use hipanel\base\ModelTrait; |
|
15
|
|
|
use hipanel\modules\finance\cart\PendingPurchaseException; |
|
16
|
|
|
use Yii; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class ServerOrderPurchase. |
|
20
|
|
|
*/ |
|
21
|
|
|
class ServerOrderPurchase extends AbstractServerPurchase |
|
22
|
|
|
{ |
|
23
|
|
|
use ModelTrait; |
|
24
|
|
|
|
|
25
|
|
|
/** {@inheritdoc} */ |
|
26
|
|
|
public static function operation() |
|
27
|
|
|
{ |
|
28
|
|
|
return 'Buy'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** {@inheritdoc} */ |
|
32
|
|
|
public function init() |
|
33
|
|
|
{ |
|
34
|
|
|
parent::init(); |
|
35
|
|
|
|
|
36
|
|
|
$this->amount = $this->position->getQuantity(); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
View Code Duplication |
public function rules() |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
return array_merge(parent::rules(), [ |
|
42
|
|
|
[['osimage', 'cluster_id', 'purpose', 'tariff_id'], 'required'], |
|
43
|
|
|
[['osimage', 'panel', 'social', 'purpose'], 'safe'], |
|
44
|
|
|
[['tariff_id', 'cluster_id'], 'integer'], |
|
45
|
|
|
]); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function execute() |
|
49
|
|
|
{ |
|
50
|
|
|
if (parent::execute()) { |
|
51
|
|
|
Yii::$app->getView()->params['remarks'][] = Yii::t('hipanel/server/order', 'You will receive an email with server access information right after setup.'); |
|
52
|
|
|
|
|
53
|
|
|
if (is_array($this->_result) && isset($this->_result['_action_pending'])) { |
|
54
|
|
|
throw new PendingPurchaseException(Yii::t('hipanel/server/order', 'Server setup will be performed as soon as manager confirms your account verification. Please wait.'), $this->position); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return true; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return false; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function renderNotes() |
|
64
|
|
|
{ |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.