|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Task runner, code generator and build tool for easier continuos integration |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hidev |
|
7
|
|
|
* @package hidev |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hidev\goals; |
|
13
|
|
|
|
|
14
|
|
|
use Yii; |
|
15
|
|
|
use yii\base\InvalidConfigException; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Goal that starts ... |
|
19
|
|
|
*/ |
|
20
|
|
|
class StartGoal extends DefaultGoal |
|
21
|
|
|
{ |
|
22
|
|
|
public function actionPerform() |
|
23
|
|
|
{ |
|
24
|
|
|
Yii::setAlias('@prjdir', $this->findDir()); |
|
25
|
|
|
$this->loadExtensions(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
protected function loadExtensions() |
|
29
|
|
|
{ |
|
30
|
|
|
$require = Yii::createObject([ |
|
31
|
|
|
'class' => 'hidev\base\File', |
|
32
|
|
|
'path' => '.hidev/config.yml', |
|
33
|
|
|
])->load()['require']; |
|
34
|
|
|
if ($require) { |
|
35
|
|
|
Yii::createObject([ |
|
36
|
|
|
'class' => 'hidev\base\File', |
|
37
|
|
|
'path' => '.hidev/composer.json', |
|
38
|
|
|
])->save(compact('require')); |
|
39
|
|
|
if (!is_dir('.hidev/vendor')) { |
|
40
|
|
|
exec('cd .hidev;composer update --prefer-source'); |
|
41
|
|
|
} |
|
42
|
|
|
$main = Yii::getAlias('@vendor'); |
|
43
|
|
|
$local = realpath('./.hidev/vendor'); |
|
44
|
|
|
if ($local !== $main) { |
|
45
|
|
|
$this->extensions = array_merge( |
|
|
|
|
|
|
46
|
|
|
$this->prepareExtensions($main), |
|
|
|
|
|
|
47
|
|
|
$this->prepareExtensions($local) |
|
|
|
|
|
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Looks for config file in the current directory and up. |
|
55
|
|
|
* @return string path to the root directory of hidev project |
|
56
|
|
|
* @throws InvalidConfigException when failed to find |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function findDir() |
|
59
|
|
|
{ |
|
60
|
|
|
$configDir = '.hidev'; |
|
61
|
|
|
if (!$isInit) { |
|
|
|
|
|
|
62
|
|
|
for ($i = 0;$i < 9;++$i) { |
|
63
|
|
|
if (is_dir($configDir)) { |
|
64
|
|
|
return getcwd(); |
|
65
|
|
|
} |
|
66
|
|
|
chdir('..'); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
throw new InvalidConfigException('Not a hidev project (or any of the parent directories). Use `hidev init` to initialize hidev project.'); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
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.