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\backup; |
12
|
|
|
|
13
|
|
|
use hipanel\modules\hosting\models\Hdomain; |
14
|
|
|
use Yii; |
15
|
|
|
use yii\base\Widget; |
16
|
|
|
use yii\helpers\Html; |
17
|
|
|
|
18
|
|
|
class BackupGridRow extends Widget |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var \hipanel\base\Model |
22
|
|
|
*/ |
23
|
|
|
public $model; |
24
|
|
|
|
25
|
|
|
public function run() |
26
|
|
|
{ |
27
|
|
|
if ($this->model->backuping_exists) { |
28
|
|
|
return $this->generateBackupingLink(); |
29
|
|
|
} else { |
30
|
|
|
return $this->generateBackupingEnableLink(); |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function getRealObjectId() |
35
|
|
|
{ |
36
|
|
|
$id = $this->model->id; |
37
|
|
|
|
38
|
|
|
if ($this->model instanceof Hdomain) { |
39
|
|
|
$id = $this->model->isAlias() ? $this->model->vhost_id : $this->model->id; |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return $id; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected function generateBackupingLink() |
46
|
|
|
{ |
47
|
|
|
$id = $this->getRealObjectId(); |
48
|
|
|
|
49
|
|
|
$linkToBackup = Html::a('<i class="fa fa-archive" aria-hidden="true"></i> ' . |
50
|
|
|
Yii::t('hipanel:hosting', 'Backup settings'), ['@backuping/view', 'id' => $id]); |
51
|
|
|
|
52
|
|
|
return $linkToBackup; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function generateBackupingEnableLink() |
56
|
|
|
{ |
57
|
|
|
$text = '<i class="fa fa-check" aria-hidden="true"></i> '; |
58
|
|
|
$text .= Yii::t('hipanel:hosting', 'Enable backuping'); |
59
|
|
|
|
60
|
|
|
$linkToBackup = Html::a($text, [sprintf('@%s/enable-backuping', $this->model->tableName())], [ |
61
|
|
|
'data-method' => 'POST', |
62
|
|
|
'data-params' => [ |
63
|
|
|
sprintf('%s[id]', ucfirst($this->model->tableName())) => $this->getRealObjectId(), |
64
|
|
|
], |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
return $linkToBackup; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read 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.