From 876bed5f904a0c31e5b0fc9ad692ac329e9f1a8e Mon Sep 17 00:00:00 2001 From: Dmitriy Haralson Date: Tue, 14 Nov 2017 19:59:40 +0200 Subject: [PATCH] open sourcing namespace conversion --- .gitignore | 1 + Module.php | 47 ++++++------ composer.json | 38 +++++----- controllers/EnvironmentController.php | 57 +++++++------- widgets/BaseEnvironment.php | 102 +++++++++++++------------- widgets/DevelopmentEnvironment.php | 16 ++-- widgets/ProductionEnvironment.php | 16 ++-- widgets/views/prod/yii | 56 +++++++------- 8 files changed, 166 insertions(+), 167 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c3adeeb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nbproject/* \ No newline at end of file diff --git a/Module.php b/Module.php index adab0c3..1f1764a 100644 --- a/Module.php +++ b/Module.php @@ -1,24 +1,23 @@ -=2.0.6" - }, - "autoload": { - "psr-4": { - "libs8000\\consoleutils\\": "" - } - } -} +{ + "name": "dmitriyha/yii2-advanced-template-init", + "description": "Console utility to initialize and reinitialze a Yii2 application", + "type": "library", + "authors": [ + { + "name": "Dmitriy Haralson", + "email": "diharalson@gmail.com" + } + ], + "require": { + "yiisoft/yii2": ">=2.0.6" + }, + "autoload": { + "psr-4": { + "dmitriyha\\Yii2AdvancedTemplateInit\\": "" + } + } +} diff --git a/controllers/EnvironmentController.php b/controllers/EnvironmentController.php index 798dcd2..e6f6126 100644 --- a/controllers/EnvironmentController.php +++ b/controllers/EnvironmentController.php @@ -1,29 +1,28 @@ -namespaces as $namespace){ - $path = yii::getAlias($namespace); - $configFolder = $path.'/config'; - $folder = str_replace('@','',$namespace); - file_put_contents($configFolder.'/main-local.php', - $this->render( - $this->environment.'/'.$folder.'/config/main-local.php', - [ - 'dbName'=>$this->dbName, - 'dbUser'=>$this->dbUser, - 'dbPassword'=>$this->dbPassword, - 'dbHost'=>$this->dbHost, - ] - ) - ); - file_put_contents($configFolder.'/params-local.php',$this->render($this->environment.'/'.$folder.'/config/params-local.php')); - if(!file_exists($path.'/web/index.php') && $namespace !== '@common' && $namespace !== '@console'){ - if(!file_exists($path.'/web/assets')){ - mkdir($path.'/web/assets',755); - mkdir($path.'/runtime',755); - } - file_put_contents($path.'/web/index.php',$this->render($this->environment.'/'.$folder.'/web/index.php')); - } - - } - - return parent::run(); - } +namespaces as $namespace){ + $path = yii::getAlias($namespace); + $configFolder = $path.'/config'; + $folder = str_replace('@','',$namespace); + file_put_contents($configFolder.'/main-local.php', + $this->render( + $this->environment.'/'.$folder.'/config/main-local.php', + [ + 'dbName'=>$this->dbName, + 'dbUser'=>$this->dbUser, + 'dbPassword'=>$this->dbPassword, + 'dbHost'=>$this->dbHost, + ] + ) + ); + file_put_contents($configFolder.'/params-local.php',$this->render($this->environment.'/'.$folder.'/config/params-local.php')); + if(!file_exists($path.'/web/index.php') && $namespace !== '@common' && $namespace !== '@console'){ + if(!file_exists($path.'/web/assets')){ + mkdir($path.'/web/assets',755); + mkdir($path.'/runtime',755); + } + file_put_contents($path.'/web/index.php',$this->render($this->environment.'/'.$folder.'/web/index.php')); + } + + } + + return parent::run(); + } } \ No newline at end of file diff --git a/widgets/DevelopmentEnvironment.php b/widgets/DevelopmentEnvironment.php index 736c9d2..6feeb5c 100644 --- a/widgets/DevelopmentEnvironment.php +++ b/widgets/DevelopmentEnvironment.php @@ -1,9 +1,9 @@ -run(); -exit($exitCode); +#!/usr/bin/env php +run(); +exit($exitCode);