|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Automation tool mixed with code generator for easier continuous development |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hidev |
|
6
|
|
|
* @package hidev |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hidev\console; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\Yaml\Yaml; |
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Dump available definitions: components, controllers, aliases. |
|
18
|
|
|
*/ |
|
19
|
|
|
class DumpController extends \yii\console\Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public $defaultAction = 'component'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Dump defined components. |
|
25
|
|
|
* @param string $name component name |
|
26
|
|
|
*/ |
|
27
|
|
|
public function actionComponent($name = null) |
|
28
|
|
|
{ |
|
29
|
|
|
$data = Yii::$app->getComponents(); |
|
30
|
|
|
if ($name) { |
|
31
|
|
|
if (empty($data[$name])) { |
|
32
|
|
|
Yii::error("'$name' not defined"); |
|
33
|
|
|
|
|
34
|
|
|
return; |
|
35
|
|
|
} |
|
36
|
|
|
$data = [$name => $data[$name]]; |
|
37
|
|
|
} |
|
38
|
|
|
echo Yaml::dump($data, 4); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Dump defined controllers. |
|
43
|
|
|
* @param string $name controller name |
|
44
|
|
|
*/ |
|
45
|
|
|
public function actionController($name = null) |
|
46
|
|
|
{ |
|
47
|
|
|
$data = Yii::$app->controllerMap; |
|
48
|
|
|
if ($name) { |
|
49
|
|
|
if (empty($data[$name])) { |
|
50
|
|
|
Yii::error("'$name' not defined"); |
|
51
|
|
|
|
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
$data = [$name => $data[$name]]; |
|
55
|
|
|
} |
|
56
|
|
|
echo Yaml::dump($data, 4); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Dump defined aliases. |
|
61
|
|
|
* @param string $alias alias to resolve |
|
62
|
|
|
*/ |
|
63
|
|
|
public function actionAlias($alias = null) |
|
64
|
|
|
{ |
|
65
|
|
|
$data = Yii::$aliases; |
|
66
|
|
|
if ($alias) { |
|
67
|
|
|
$dest = Yii::getAlias($alias, false); |
|
68
|
|
|
if (empty($dest)) { |
|
69
|
|
|
Yii::error("'$alias' not defined"); |
|
70
|
|
|
|
|
71
|
|
|
return; |
|
72
|
|
|
} |
|
73
|
|
|
$data = [$alias => $dest]; |
|
74
|
|
|
} |
|
75
|
|
|
echo Yaml::dump($data, 4); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|