1 | <?php |
||
23 | class Application extends \yii\console\Application implements ViewContextInterface |
||
24 | { |
||
25 | protected $_viewPath; |
||
26 | |||
27 | protected $_config; |
||
28 | |||
29 | protected $_first = true; |
||
30 | |||
31 | 5 | public function __construct($config = []) |
|
32 | { |
||
33 | 5 | $this->_config = $config; |
|
34 | parent::__construct($config); |
||
35 | 5 | } |
|
36 | |||
37 | /** |
||
38 | * Creates application with given config and runs it. |
||
39 | * @param array $config |
||
40 | * @return int exit code |
||
41 | */ |
||
42 | public static function main(array $config) |
||
43 | { |
||
44 | try { |
||
45 | $app = static::create($config); |
||
46 | $exitCode = $app->run(); |
||
47 | } catch (Exception $e) { |
||
48 | /*if ($e instanceof InvalidParamException || $e instanceof ConsoleException) { |
||
|
|||
49 | Yii::error($e->getMessage()); |
||
50 | $exitCode = 1; |
||
51 | } else { |
||
52 | throw $e; |
||
53 | }*/ |
||
54 | throw $e; |
||
55 | } |
||
56 | |||
57 | return $exitCode; |
||
58 | } |
||
59 | |||
60 | 5 | public static function create(array $config) |
|
61 | { |
||
62 | Yii::setLogger(Yii::createObject('hidev\base\Logger')); |
||
63 | $config = ArrayHelper::merge( |
||
64 | 5 | static::readExtraVendor($config['vendorPath']), |
|
65 | $config |
||
66 | ); |
||
67 | |||
68 | return new static($config); |
||
69 | 5 | } |
|
70 | |||
71 | public static function readExtraVendor($dir) |
||
75 | |||
76 | public static function readExtraConfig($path) |
||
77 | { |
||
78 | $path = Yii::getAlias($path); |
||
82 | |||
83 | 2 | public function loadExtraConfig($path) |
|
87 | |||
88 | /** |
||
89 | * Load extra config files. |
||
90 | * @param array $config |
||
91 | */ |
||
92 | public function loadExtraVendor($dir) |
||
96 | |||
97 | /** |
||
98 | * Implements extra configuration. |
||
99 | * @param array $config |
||
100 | */ |
||
101 | 2 | public function setExtraConfig($config) |
|
115 | |||
116 | /** |
||
117 | * Implements extra params. |
||
118 | * @param array $params |
||
119 | */ |
||
120 | public function setExtraParams($params) |
||
126 | |||
127 | /** |
||
128 | * Implements extra aliases. |
||
129 | * @param array $aliases |
||
130 | */ |
||
131 | 2 | public function setExtraAliases($aliases) |
|
137 | |||
138 | /** |
||
139 | * Implements extra modules. |
||
140 | * @param array $modules |
||
141 | */ |
||
142 | public function setExtraModules($modules) |
||
148 | |||
149 | /** |
||
150 | * Implements extra components. |
||
151 | * Does NOT touch already instantiated components. |
||
152 | * @param array $components |
||
153 | */ |
||
154 | 2 | public function setExtraComponents($components) |
|
165 | |||
166 | 5 | public function createControllerByID($id) |
|
186 | |||
187 | /** |
||
188 | * Run request. |
||
189 | * @param string|array $query |
||
190 | * @return Response |
||
191 | */ |
||
192 | 3 | public function runRequest($query) |
|
201 | } |
||
202 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.