/** * Internal use ONLY! * Setup the PipelineSupport from the global Environment. * * @param string $connectionName the name of the database connection * @param string $tableName the name of the table inside the database connection * * @throws DatabaseException the exception occurred while fetching the database connection * @throws \InvalidArgumentException given arguments are not valid strings */ public static function Initialize($connectionName, $tableName) { //only works for the first time (prevent user from doing bad things) if (self::$initialized) { return; } self::$initialized = true; if (!is_string($connectionName) || !is_string($tableName)) { throw new \InvalidArgumentException('Database connection name and table must be given as strings'); } //retrieve the database connection self::$connectionHandler = \Gishiki\Database\DatabaseManager::Retrieve($connectionName); //store the table name self::$tableName = $tableName; }
/** * Load the framework configuration from the config file and return it in an * format kwnown to the framework. */ private function loadConfiguration() { //get the security configuration of the current application $config = []; if (self::applicationExists()) { $config = self::getApplicationSettings(); //General Configuration $this->configuration = ['DEVELOPMENT_ENVIRONMENT' => isset($config['general']['development']) ? $config['general']['development'] : false, 'AUTOLOG_URL' => isset($config['general']['autolog']) ? $config['general']['autolog'] : 'null', 'SECURITY' => ['MASTER_SYMMETRIC_KEY' => $config['security']['serverPassword'], 'MASTER_ASYMMETRIC_KEY' => $config['security']['serverKey']], 'CONNECTIONS' => array_key_exists('connections', $config) ? $config['connections'] : array(), 'PIPELINE' => ['CONNECTION' => isset($config['pipeline']['connection']) ? $config['pipeline']['connection'] : null, 'COLLECTION' => isset($config['pipeline']['collection']) ? $config['pipeline']['collection'] : null]]; } //check for the environment configuration if ($this->configuration['DEVELOPMENT_ENVIRONMENT']) { ini_set('display_errors', 1); error_reporting(E_ALL); } else { ini_set('display_errors', 0); error_reporting(0); } //connect every db connection foreach ($this->configuration['CONNECTIONS'] as $connection) { \Gishiki\Database\DatabaseManager::Connect($connection['name'], $connection['query']); } //setup the pipeline execution support \Gishiki\Pipeline\PipelineSupport::Initialize($this->GetConfigurationProperty('PIPELINE_CONNECTION_NAME'), $this->GetConfigurationProperty('PIPELINE_TABLE_NAME')); }