From 0621edb82f8ad22f83d5dfc110a66233ecc4ca09 Mon Sep 17 00:00:00 2001 From: Andrii Vasyliev Date: Mon, 8 May 2017 21:21:36 +0200 Subject: [PATCH] renamed `console` <- controllers --- src/base/Controller.php | 2 +- src/base/Starter.php | 13 ++++++++++++- src/config/basis.php | 10 +++++----- src/{controllers => console}/CommonBehavior.php | 2 +- src/{controllers => console}/CommonController.php | 2 +- src/{controllers => console}/DumpController.php | 2 +- src/{controllers => console}/GitController.php | 2 +- src/{controllers => console}/GithubController.php | 2 +- .../GitignoreController.php | 2 +- src/{controllers => console}/InitController.php | 2 +- .../SvnignoreController.php | 2 +- .../VcsignoreController.php | 2 +- src/{controllers => console}/VersionController.php | 2 +- 13 files changed, 28 insertions(+), 17 deletions(-) rename src/{controllers => console}/CommonBehavior.php (98%) rename src/{controllers => console}/CommonController.php (96%) rename src/{controllers => console}/DumpController.php (98%) rename src/{controllers => console}/GitController.php (97%) rename src/{controllers => console}/GithubController.php (99%) rename src/{controllers => console}/GitignoreController.php (92%) rename src/{controllers => console}/InitController.php (99%) rename src/{controllers => console}/SvnignoreController.php (93%) rename src/{controllers => console}/VcsignoreController.php (93%) rename src/{controllers => console}/VersionController.php (97%) diff --git a/src/base/Controller.php b/src/base/Controller.php index 68d72d6..a976bc4 100644 --- a/src/base/Controller.php +++ b/src/base/Controller.php @@ -10,7 +10,7 @@ namespace hidev\base; -use hidev\controllers\CommonBehavior; +use hidev\console\CommonBehavior; /** * Basic controller. diff --git a/src/base/Starter.php b/src/base/Starter.php index 7df6bd2..3296d34 100644 --- a/src/base/Starter.php +++ b/src/base/Starter.php @@ -74,6 +74,7 @@ public function startProject() $this->loadEnv(); $this->loadGoals(); $this->addAliases(); + $this->addAutoloader(); $this->requireAll(); $this->includeAll(); $this->moreConfig(); @@ -104,7 +105,7 @@ public function getConfig() if (!empty($config['controllerMap'])) { foreach ($config['controllerMap'] as &$def) { if (is_array($def) && empty($def['class'])) { - $def['class'] = \hidev\controllers\CommonController::class; + $def['class'] = \hidev\console\CommonController::class; } } } @@ -207,6 +208,16 @@ private function hasAlias($alias, $exact = true) return $pos === false ? isset(Yii::$aliases[$alias]) : isset(Yii::$aliases[substr($alias, 0, $pos)][$alias]); } + public function addAutoloader() + { + $autoloader = './vendor/autoload.php'; + if (file_exists($autoloader)) { + spl_autoload_unregister(['Yii', 'autoload']); + require $autoloader; + spl_autoload_register(['Yii', 'autoload'], true, true); + } + } + /** * - install configured plugins and register their app config * - install project dependencies and register diff --git a/src/config/basis.php b/src/config/basis.php index 6263460..4018eb5 100644 --- a/src/config/basis.php +++ b/src/config/basis.php @@ -20,7 +20,7 @@ 'basePath' => dirname(__DIR__), 'vendorPath' => HIDEV_VENDOR_DIR, 'runtimePath' => $runtimePath, - 'controllerNamespace' => 'hidev\\controllers', + 'controllerNamespace' => 'hidev\\console', 'defaultRoute' => 'default', 'bootstrap' => ['log'], 'components' => [ @@ -92,17 +92,17 @@ ], 'controllerMap' => [ '--version' => [ - 'class' => \hidev\controllers\VersionController::class, + 'class' => \hidev\console\VersionController::class, 'own' => true, ], '.gitignore' => [ - 'class' => \hidev\controllers\GitignoreController::class, + 'class' => \hidev\console\GitignoreController::class, ], 'github' => [ - 'class' => \hidev\controllers\GithubController::class, + 'class' => \hidev\console\GithubController::class, ], 'dump' => [ - 'class' => \hidev\controllers\DumpController::class, + 'class' => \hidev\console\DumpController::class, ], ], 'container' => [ diff --git a/src/controllers/CommonBehavior.php b/src/console/CommonBehavior.php similarity index 98% rename from src/controllers/CommonBehavior.php rename to src/console/CommonBehavior.php index 0a4e0f5..c161588 100644 --- a/src/controllers/CommonBehavior.php +++ b/src/console/CommonBehavior.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; use hidev\base\Controller; use Yii; diff --git a/src/controllers/CommonController.php b/src/console/CommonController.php similarity index 96% rename from src/controllers/CommonController.php rename to src/console/CommonController.php index e67a216..e343c40 100644 --- a/src/controllers/CommonController.php +++ b/src/console/CommonController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; use Yii; diff --git a/src/controllers/DumpController.php b/src/console/DumpController.php similarity index 98% rename from src/controllers/DumpController.php rename to src/console/DumpController.php index 1b528e7..62358ab 100644 --- a/src/controllers/DumpController.php +++ b/src/console/DumpController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; use Symfony\Component\Yaml\Yaml; use Yii; diff --git a/src/controllers/GitController.php b/src/console/GitController.php similarity index 97% rename from src/controllers/GitController.php rename to src/console/GitController.php index dcc195e..79e8a4e 100644 --- a/src/controllers/GitController.php +++ b/src/console/GitController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; /** * Git. diff --git a/src/controllers/GithubController.php b/src/console/GithubController.php similarity index 99% rename from src/controllers/GithubController.php rename to src/console/GithubController.php index 0c11f61..1cb2037 100644 --- a/src/controllers/GithubController.php +++ b/src/console/GithubController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; use yii\helpers\Json; diff --git a/src/controllers/GitignoreController.php b/src/console/GitignoreController.php similarity index 92% rename from src/controllers/GitignoreController.php rename to src/console/GitignoreController.php index 354ff6a..04ff119 100644 --- a/src/controllers/GitignoreController.php +++ b/src/console/GitignoreController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; /** * `.gitignore` file generation. diff --git a/src/controllers/InitController.php b/src/console/InitController.php similarity index 99% rename from src/controllers/InitController.php rename to src/console/InitController.php index 3925478..3d349b1 100644 --- a/src/controllers/InitController.php +++ b/src/console/InitController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; use Exception; use hidev\base\File; diff --git a/src/controllers/SvnignoreController.php b/src/console/SvnignoreController.php similarity index 93% rename from src/controllers/SvnignoreController.php rename to src/console/SvnignoreController.php index 20300b3..486cecf 100644 --- a/src/controllers/SvnignoreController.php +++ b/src/console/SvnignoreController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; /** * Controller for svn:ignore. diff --git a/src/controllers/VcsignoreController.php b/src/console/VcsignoreController.php similarity index 93% rename from src/controllers/VcsignoreController.php rename to src/console/VcsignoreController.php index ed6ccd1..99318ec 100644 --- a/src/controllers/VcsignoreController.php +++ b/src/console/VcsignoreController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; /** * VCS ignore file generation. diff --git a/src/controllers/VersionController.php b/src/console/VersionController.php similarity index 97% rename from src/controllers/VersionController.php rename to src/console/VersionController.php index 093e1ce..2c74acd 100644 --- a/src/controllers/VersionController.php +++ b/src/console/VersionController.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) */ -namespace hidev\controllers; +namespace hidev\console; /** * Version management.