Updating PHPCI to use YAML-based config files.

This commit is contained in:
Dan Cryer 2013-05-23 12:10:01 +01:00
commit ce6943de86
3 changed files with 48 additions and 35 deletions

View file

@ -36,20 +36,43 @@ if (!defined('APPLICATION_PATH')) {
require_once(APPLICATION_PATH . 'vendor/autoload.php');
// Load configuration if present:
$config = new b8\Config();
$conf = array();
$conf['b8']['app']['namespace'] = 'PHPCI';
$conf['b8']['app']['default_controller'] = 'Index';
$conf['b8']['view']['path'] = dirname(__FILE__) . '/PHPCI/View/';
$config = new b8\Config($conf);
$request = new b8\Http\Request();
$registry = new b8\Registry($config, $request);
if (file_exists(APPLICATION_PATH . 'config.php')) {
require(APPLICATION_PATH . 'config.php');
// Define our PHPCI_URL, if not already defined:
if (!defined('PHPCI_URL')) {
define('PHPCI_URL', $config->get('install_url', '') . '/');
$conf = $config->get(null);
unset($conf['b8']['app']);
unset($conf['b8']['view']);
$conf['phpci']['url'] = $conf['install_url'];
if (isset($conf['github_app'])) {
$conf['phpci']['github'] = $conf['github_app'];
}
unset($conf['install_url']);
unset($conf['github_app']);
$dumper = new Symfony\Component\Yaml\Dumper();
$yaml = $dumper->dump($conf);
file_put_contents(APPLICATION_PATH . 'PHPCI/config.yml', $yaml);
unlink(APPLICATION_PATH . 'config.php');
}
// Set up the registry:
$config->set('app_namespace', 'PHPCI');
$config->set('default_controller', 'Index');
$config->set('view_path', dirname(__FILE__) . '/PHPCI/View/');
if (file_exists(APPLICATION_PATH . 'PHPCI/config.yml')) {
$config->loadYaml(APPLICATION_PATH . 'PHPCI/config.yml');
// Define our PHPCI_URL, if not already defined:
if (!defined('PHPCI_URL')) {
define('PHPCI_URL', $config->get('phpci.url', '') . '/');
}
}