/** * \Phalcon\Config\Adapter\Ini constructor * * @param string $filePath * @throws Exception */ public function __construct($filePath) { $array = array(); if (is_string($filePath) === false) { throw new Exception('Invalid parameter type.'); } @($d = parse_ini_file($filePath, true)); if ($d === false) { throw new Exception('Configuration file ' . $filePath . " can't be loaded"); } foreach ($d as $section => $directives) { if (is_array($directives) === false || empty($directives) === true) { $array[$section] = $directives; } else { foreach ($directives as $key => $value) { if (strpos($key, '.') !== false) { isset($array[$section]) === false && ($array[$section] = array()); $array[$section] = self::_parseKey($array[$section], $key, $value); } else { $array[$section][$key] = $value; } } } } parent::__construct($array); }
/** * Phalcon\Config\Adapter\Yaml * * @param string $filePath */ public function __construct($filePath, $callbacks = array()) { if (!extension_loaded('yaml')) { throw new Exception('Yaml extension not loaded'); } if (false === ($result = @yaml_parse_file($filePath, 0, $ndocs, $callbacks))) { throw new Exception('Configuration file ' . $filePath . ' can\'t be loaded'); } parent::__construct($result); }
/** * Class constructor. * * @param string $filePath * @throws \Phalcon\Config\Exception */ public function __construct($filePath) { if (!extension_loaded("json")) { throw new Exception('Json extension not loaded'); } if (false === ($result = json_decode(file_get_contents($filePath), true))) { throw new Exception('Configuration file ' . $filePath . ' can\'t be loaded'); } parent::__construct($result); }
/** * \Phalcon\Config\Adapter\Json constructor * * @param string $filePath * @throws Exception */ public function __construct($filePath) { if (is_string($filePath) === false) { throw new Exception('Invalid parameter type.'); } @($contents = file_get_contents($filePath)); if (is_string($contents) === true) { $array = json_decode($contents, true); if (json_last_error() !== \JSON_ERROR_NONE) { throw new Exception('Invalid json file.'); } parent::__construct($array); } else { throw new Exception('Unable to read json file.'); } }
/** * Phalcon\Config\Adapter\Xml constructor * * @param string $filePath * @throws Exception */ public function __construct($filePath) { if (!extension_loaded('SimpleXML')) { throw new Exception("SimpleXML extension not loaded"); } libxml_use_internal_errors(true); $data = simplexml_load_file($filePath, 'SimpleXMLElement', LIBXML_NOCDATA); foreach (libxml_get_errors() as $error) { /** @var \LibXMLError $error */ switch ($error->code) { case LIBXML_ERR_WARNING: trigger_error($error->message, E_USER_WARNING); break; default: throw new Exception($error->message); } } libxml_use_internal_errors(false); parent::__construct(json_decode(json_encode((array) $data), true)); }
/** * Options Constructor * * @param array $options * * @throws \InvalidArgumentException If flags is not an integer */ public function __construct(array $options) { parent::__construct($options); }
/** * Create configuration object. * * @param array|null $arrayConfig Configuration data. * @param string|null $stage Configuration stage. */ public function __construct($arrayConfig = null, $stage = null) { $this->_currentStage = $stage; parent::__construct($arrayConfig); }
public function __construct($file_path) { parent::__construct(json_decode(file_get_contents($file_path))); }
public function __construct(array $arrayConfig = null) { parent::__construct($arrayConfig); }
public function __construct() { $this->yaml = new Yaml(__DIR__ . '/../phinx.yml'); parent::__construct(array_merge($this->setupDB(), $this->setupApplication())); }
public function __construct($path) { parent::__construct(YamlParser::parse($path)); }
public function __construct() { $config = ['database' => ['adapter' => 'Mysql', 'host' => 'localhost', 'username' => 'root', 'password' => '', 'name' => 'test']]; parent::__construct($config); }