|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Travis CI plugin for HiDev. |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hidev-travis |
|
6
|
|
|
* @package hidev-travis |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hidev\travis\console; |
|
12
|
|
|
|
|
13
|
|
|
use hidev\helpers\Helper; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Travis CI. |
|
17
|
|
|
*/ |
|
18
|
|
|
class TravisController extends \hidev\base\Controller |
|
19
|
|
|
{ |
|
20
|
|
|
public $defaultAction = 'run'; |
|
21
|
|
|
|
|
22
|
|
|
public function actionRun() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->runActions(['before-install', 'install']); |
|
25
|
|
|
$res = $this->runActions(['before-script', 'script']); |
|
26
|
|
|
$this->runAction(!Helper::isResponseOk($res) ? 'after-failure' : 'after-success'); |
|
27
|
|
|
$this->runAction('after-script'); |
|
28
|
|
|
|
|
29
|
|
|
return $res; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function actionBeforeInstall() |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->runRequests($this->getComponent()->before_install); |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function actionInstall() |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->runRequests($this->getComponent()->install); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function actionBeforeScript() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->runRequests($this->getComponent()->before_script); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function actionScript() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->runRequests($this->getComponent()->script); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function actionAfterSuccess() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->runRequests($this->getComponent()->after_success); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function actionAfterFailure() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->runRequests($this->getComponent()->after_failure); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function actionAfterScript() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->runRequests($this->getComponent()->after_script); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getComponent() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->take('travis'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: