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
|
|
|
/** |
12
|
|
|
* @see http://hiqdev.com/hipanel-module-hosting |
13
|
|
|
* @license http://hiqdev.com/hipanel-module-hosting/license |
14
|
|
|
* @copyright Copyright (c) 2015 HiQDev |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace hipanel\modules\hosting\models; |
18
|
|
|
|
19
|
|
|
class Crontab extends \hipanel\base\Model |
20
|
|
|
{ |
21
|
|
|
use \hipanel\base\ModelTrait; |
22
|
|
|
|
23
|
|
|
/** {@inheritdoc} */ |
24
|
|
|
public function rules() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
[['id', 'account_id', 'server_id', 'client_id'], 'integer'], |
28
|
|
|
[['crontab', 'account', 'server', 'client'], 'safe'], |
29
|
|
|
[['state', 'state_label'], 'safe'], |
30
|
|
|
[['exists'], 'boolean'], |
31
|
|
|
|
32
|
|
|
// Update |
33
|
|
|
[['id'], 'integer', 'on' => ['update']], |
34
|
|
|
[['crontab'], 'string', 'on' => ['update']], |
35
|
|
|
|
36
|
|
|
[['id'], 'integer', 'on' => ['request-fetch', 'get-request-state']], |
37
|
|
|
]; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** {@inheritdoc} */ |
41
|
|
|
public function attributeLabels() |
42
|
|
|
{ |
43
|
|
|
return $this->mergeAttributeLabels([]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return int |
48
|
|
|
*/ |
49
|
|
|
public function getCronRecordCount() |
50
|
|
|
{ |
51
|
|
|
$count = 0; |
52
|
|
|
$regex = '/^(\s+)?(#.*)?$/'; |
53
|
|
|
foreach (explode("\n", $this->crontab) as $line) { |
|
|
|
|
54
|
|
|
if (!preg_match($regex, trim($line))) { |
55
|
|
|
++$count; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $count; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
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.