Ejemplo n.º 1
0
 /**
  * \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);
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * \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.');
     }
 }
Ejemplo n.º 5
0
 /**
  * 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));
 }
Ejemplo n.º 6
0
 /**
  * Options Constructor
  *
  * @param array $options
  *
  * @throws \InvalidArgumentException If flags is not an integer
  */
 public function __construct(array $options)
 {
     parent::__construct($options);
 }
Ejemplo n.º 7
0
 /**
  * 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);
 }
Ejemplo n.º 8
0
 public function __construct($file_path)
 {
     parent::__construct(json_decode(file_get_contents($file_path)));
 }
Ejemplo n.º 9
0
 public function __construct(array $arrayConfig = null)
 {
     parent::__construct($arrayConfig);
 }
Ejemplo n.º 10
0
 public function __construct()
 {
     $this->yaml = new Yaml(__DIR__ . '/../phinx.yml');
     parent::__construct(array_merge($this->setupDB(), $this->setupApplication()));
 }
Ejemplo n.º 11
0
 public function __construct($path)
 {
     parent::__construct(YamlParser::parse($path));
 }
Ejemplo n.º 12
0
 public function __construct()
 {
     $config = ['database' => ['adapter' => 'Mysql', 'host' => 'localhost', 'username' => 'root', 'password' => '', 'name' => 'test']];
     parent::__construct($config);
 }