static function get($root, $regen = false) { if (is_null(self::$env) || $regen) { self::$env = Gongo_Locator::get('Gongo_App_Environment', $root); } return self::$env; }
static function initializeApplication($app, $path = null) { if (!is_null($path) && is_null(self::$appRootPath)) { self::$appRootPath = $path; if (is_null(self::$environment)) { self::$environment = Gongo_App_Environment::get(self::$appRootPath); } if (is_null(self::cfg())) { self::cfg(self::$environment->config); } // Locator $locator = Gongo_Locator::getInstance(); $locator->config(self::$environment->config); $gongoBuilderClass = self::cfg()->Locator->Gongo_Builder; if ($gongoBuilderClass) { $locator->injectBuilder($gongoBuilderClass); self::$environment = Gongo_App_Environment::get(self::$appRootPath, true); self::cfg(self::$environment->config); } $errorReporting = self::cfg()->Error->error_reporting; if ($errorReporting) { error_reporting($errorReporting); } // autoloader spl_autoload_register('Gongo_App::autoload'); // preload self::preload(); } if (is_null(self::$application)) { self::$application = $app; } return $app; }
public function get($env) { if (!Gongo_App_Environment::read('GONGO_OVERRIDE_DB_CONFIG')) { $dsn = $env->config->Database->dsn; $user = $env->config->Database->user; $password = $env->config->Database->password; } else { if ($env->devMode) { $dsn = Gongo_App_Environment::read('GONGO_DEVELOPMENT_DB_DSN'); $user = Gongo_App_Environment::read('GONGO_DEVELOPMENT_DB_USER'); $password = Gongo_App_Environment::read('GONGO_DEVELOPMENT_DB_PASSWORD'); } else { $dsn = Gongo_App_Environment::read('GONGO_PRODUCTION_DB_DSN'); $user = Gongo_App_Environment::read('GONGO_PRODUCTION_DB_USER'); $password = Gongo_App_Environment::read('GONGO_PRODUCTION_DB_PASSWORD'); } } $options = $this->getOptions($env, $dsn); $pdo = new PDO($dsn, $user, $password, $options); return $pdo; }