mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 19:20:56 +01:00
Add fromFile factory method to GitList\Config
This commit is contained in:
2
boot.php
2
boot.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// Load configuration
|
||||
$config = new GitList\Config('config.ini');
|
||||
$config = GitList\Config::fromFile('config.ini');
|
||||
$config->set('git', 'repositories', rtrim($config->get('git', 'repositories'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Startup and configure Silex application
|
||||
|
||||
@@ -6,13 +6,17 @@ class Config
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($file)
|
||||
{
|
||||
public static function fromFile($file) {
|
||||
if (!file_exists($file)) {
|
||||
die(sprintf('Please, create the %1$s file.', $file));
|
||||
}
|
||||
$data = parse_ini_file($file, true);
|
||||
return new static($data);
|
||||
}
|
||||
|
||||
$this->data = parse_ini_file($file, true);
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->validateOptions();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user