1 | <?php |
||
17 | class AppController extends Controller |
||
18 | { |
||
19 | public $defaultAction = 'version'; |
||
20 | |||
21 | /** |
||
22 | * Shows application configuration |
||
23 | * Note that this action shows console configuration. |
||
24 | * |
||
25 | * @param null $key configuration section |
||
26 | */ |
||
27 | public function actionConfig($key = null) |
||
|
|||
28 | { |
||
29 | // get config from global variable (TODO) |
||
30 | $data = $GLOBALS['config']; |
||
31 | if ($key) { |
||
32 | $keys = explode('.', $key); |
||
33 | if (isset($keys[0])) { |
||
34 | $data = $GLOBALS['config'][$keys[0]]; |
||
35 | } |
||
36 | if (isset($keys[1])) { |
||
37 | $data = $GLOBALS['config'][$keys[0]][$keys[1]]; |
||
38 | } |
||
39 | } |
||
40 | $this->stdout(VarDumper::dumpAsString($data)); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Shows application environment variables. |
||
45 | */ |
||
46 | public function actionEnv() |
||
47 | { |
||
48 | $env = $_ENV; |
||
49 | ksort($env); |
||
50 | $this->stdout(VarDumper::dumpAsString($env)); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Displays application version from APP_VERSION constant. |
||
55 | */ |
||
56 | public function actionVersion($alias = '@app/version') |
||
63 | |||
64 | /** |
||
65 | * Initializes application. |
||
66 | */ |
||
67 | public function actionSetup() |
||
93 | |||
94 | /** |
||
95 | * Clean cache, assets and audit tables |
||
96 | */ |
||
97 | public function actionCleanup(){ |
||
104 | |||
105 | /** |
||
106 | * Clear [application]/web/assets folder. |
||
107 | */ |
||
108 | public function actionClearAssets() |
||
134 | } |
||
135 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: