/** * Convenience function to update all required CakePHP2 configuration files. * * @param string $appdir Full path to the application directory (APP). * @param string $url FQDN used to expose the application. * @return boolean True if the file was updated successfully */ public function updateCake2Configuration($appdir, $url) { # Update salt/cipher in core.php $this->_log("Updating core.php"); $coreFile = $appdir . DS . "app" . DS . "Config" . DS . "core.php"; $res = CakeboxUtility::updateConfigFile($coreFile, [$this->Info->frameworkMeta['cakephp2']['salt'] => CakeboxUtility::getSaltCipher($coreFile), $this->Info->frameworkMeta['cakephp2']['cipher'] => CakeboxUtility::getSaltCipher($coreFile)]); if (!$res) { $this->_error("Error updating core file"); return false; } // create database.php $dbFileSource = $appdir . DS . "app" . DS . "Config" . DS . "database.php.default"; $dbFileTarget = $appdir . DS . "app" . DS . "Config" . DS . "database.php"; if (!file_exists($dbFileTarget)) { copy($dbFileSource, $dbFileTarget); $this->_log("Created database file `{$dbFileTarget}`"); } # update database.php $this->_log("Updating database.php"); $database = CakeboxUtility::normalizeDatabaseName($url); $result = CakeboxUtility::updateConfigFile($dbFileTarget, ['test_database_name' => 'test_' . $database, 'database_name' => $database, 'user' => 'cakebox', "'password' => 'password'" => "'password' => 'secret'"]); if (!$result) { $this->_error("Error updating database file"); return false; } # Enable debugkit in bootstrap.php $this->_log("Enabling DebugKit"); $bootstrapFile = $appdir . DS . "app" . DS . "Config" . DS . "bootstrap.php"; $fh = new File($bootstrapFile); $fh->append('CakePlugin::loadAll();'); return true; }
/** * Set database name to be used for the application * * @return void */ protected function _setDatabase() { $this->options['database'] = CakeboxUtility::normalizeDatabaseName($this->options['url']); }