From 8697de008152a49510d71ad48c7f595a6720be22 Mon Sep 17 00:00:00 2001 From: wandersonwhcr Date: Wed, 21 Jul 2010 04:15:07 +0000 Subject: [PATCH] =?UTF-8?q?Cria=C3=A7=C3=A3o=20da=20estrutura=20de=20diret?= =?UTF-8?q?=C3=B3rios=20para=20as=20configura=C3=A7=C3=B5es=20do=20sistema?= =?UTF-8?q?=20conforme=20padr=C3=A3o=20de=20Arquitetura=20de=20aplicativos?= =?UTF-8?q?=20do=20Zend=20Framework.=20Construtor=20de=20arquivos=20de=20c?= =?UTF-8?q?onfigura=C3=A7=C3=A3o=20e=20tratamento=20de=20tipo=20de=20adapt?= =?UTF-8?q?ador=20de=20banco=20de=20dados,=20dando=20suporte=20somente=20a?= =?UTF-8?q?o=20MySQL=20e=20PostgreSQL.=20Arquivo=20de=20sa=C3=ADda=20de=20?= =?UTF-8?q?dados=20para=20configura=C3=A7=C3=A3o=20do=20aplicativo.=20Arqu?= =?UTF-8?q?ivo=20de=20Bootstrap=20do=20aplicativo=20Zend=20Framework.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restrict/modules/Mimoza/Mimoza.php | 2 + .../modules/Mimoza/builders/Configuration.php | 56 +++++++++++++++++++ .../data/structure/project/public/index.php | 30 ++++++++++ .../Mimoza/sources/configuration.phtml | 28 ++++++++++ 4 files changed, 116 insertions(+) create mode 100644 restrict/modules/Mimoza/builders/Configuration.php create mode 100644 restrict/modules/Mimoza/data/structure/project/public/index.php create mode 100644 restrict/modules/Mimoza/sources/configuration.phtml diff --git a/restrict/modules/Mimoza/Mimoza.php b/restrict/modules/Mimoza/Mimoza.php index c542a04..62acc05 100644 --- a/restrict/modules/Mimoza/Mimoza.php +++ b/restrict/modules/Mimoza/Mimoza.php @@ -126,6 +126,8 @@ class Mimoza extends Module implements Module_Interface { $htaccess = $this->getProject()->buildHtaccess(null); $this->getFramework()->mkFile('project/public/.htaccess', $htaccess); + $configuration = $this->getProject()->buildConfiguration(null); + $this->getFramework()->mkFile('project/application/configs/application.ini', $configuration); return $this; } diff --git a/restrict/modules/Mimoza/builders/Configuration.php b/restrict/modules/Mimoza/builders/Configuration.php new file mode 100644 index 0000000..4d8404e --- /dev/null +++ b/restrict/modules/Mimoza/builders/Configuration.php @@ -0,0 +1,56 @@ +getProject(); + $mind = $project->getMindProject(); + + $this->adapter = $this->convertPdo($mind->dbms); + + $this->production = array( + 'host' => $mind->environment['production']['dbAddress'], + 'dbname' => $mind->environment['production']['dbName'], + 'username' => $mind->environment['production']['user'], + 'password' => $mind->environment['production']['userPwd'], + ); + + $this->development = array( + 'host' => $mind->environment['development']['dbAddress'], + 'dbname' => $mind->environment['development']['dbName'], + 'username' => $mind->environment['development']['user'], + 'password' => $mind->environment['development']['userPwd'], + ); + + return $this->render('configuration.phtml'); + } + + /** + * + * Conversão de Tipo de Banco de Dados + * @param string $source Nome de Banco de Dados do Webmind + * @return string Nome de Adaptador de Banco de Dados do Zend Framework + */ + public function convertPdo($source) + { + $adapter = null; + switch(strtolower($source)) { + case 'mysql': + $adapter = 'pdo_mysql'; + break; + case 'postgresql': + $adapter = 'pdo_pgsql'; + break; + } + return $adapter; + } +} \ No newline at end of file diff --git a/restrict/modules/Mimoza/data/structure/project/public/index.php b/restrict/modules/Mimoza/data/structure/project/public/index.php new file mode 100644 index 0000000..144fc30 --- /dev/null +++ b/restrict/modules/Mimoza/data/structure/project/public/index.php @@ -0,0 +1,30 @@ +bootstrap()->run(); +} catch (Exception $e) { + header('Content-type: text/plain'); + echo $e; +} \ No newline at end of file diff --git a/restrict/modules/Mimoza/sources/configuration.phtml b/restrict/modules/Mimoza/sources/configuration.phtml new file mode 100644 index 0000000..765b77c --- /dev/null +++ b/restrict/modules/Mimoza/sources/configuration.phtml @@ -0,0 +1,28 @@ +[production] +phpSettings.display_startup_errors = 0 +phpSettings.display_errors = 0 +autoloaderNamespaces[] = "System_" +includePaths.library = APPLICATION_PATH "/../library" +bootstrap.path = APPLICATION_PATH "/Bootstrap.php" +bootstrap.class = "Bootstrap" +appnamespace = "Application" +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.params.displayExceptions = 0 +resources.db.adapter = "adapter ?>" +resources.db.params.host = "production['host'] ?>" +resources.db.params.username = "production['username'] ?>" +resources.db.params.password = "production['password'] ?>" +resources.db.params.dbname = "production['dbname'] ?>" +resources.db.isDefaultTableAdapter = "true" +resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" +resources.locale.default = "pt_BR" +resources.locale.force = true + +[development : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +resources.frontController.params.displayExceptions = 1 +resources.db.params.host = "development['host'] ?>" +resources.db.params.username = "development['username'] ?>" +resources.db.params.password = "development['password'] ?>" +resources.db.params.dbname = "development['dbname'] ?>" \ No newline at end of file