Example #1
0
 /**
  * Read and set Xajax options from a PHP config file
  *
  * @param array         $sConfigFile        The full path to the config file
  * @param string        $sKeys                The keys of the options in the file
  *
  * @return void
  */
 public static function read($sConfigFile, $sKey = '')
 {
     $sConfigFile = realpath($sConfigFile);
     if (!is_readable($sConfigFile)) {
         throw new \Xajax\Exception\Config\File('access', $sConfigFile);
     }
     $aConfigOptions = (include $sConfigFile);
     if (!is_array($aConfigOptions)) {
         throw new \Xajax\Exception\Config\File('content', $sConfigFile);
     }
     // Content read from config file. Try to parse.
     Config::setOptions($aConfigOptions, $sKey);
 }
Example #2
0
 /**
  * Read and set Xajax options from a JSON formatted config file
  *
  * @param array         $sConfigFile        The full path to the config file
  * @param string        $sKeys                The keys of the options in the file
  *
  * @return void
  */
 public static function read($sConfigFile, $sKey = '')
 {
     $sConfigFile = realpath($sConfigFile);
     if (!is_readable($sConfigFile)) {
         throw new \Xajax\Exception\Config\File('access', $sConfigFile);
     }
     $sFileContent = file_get_contents($sConfigFile);
     $aConfigOptions = json_decode($sFileContent, true);
     if (!is_array($aConfigOptions)) {
         throw new \Xajax\Exception\Config\File('content', $sConfigFile);
     }
     // Content read from config file. Try to parse.
     Config::setOptions($aConfigOptions, $sKey);
 }
Example #3
0
 /**
  * Read and set Xajax options from a YAML formatted config file
  *
  * @param array         $sConfigFile        The full path to the config file
  * @param string        $sKeys                The keys of the options in the file
  *
  * @return void
  */
 public static function read($sConfigFile, $sKey = '')
 {
     $sConfigFile = realpath($sConfigFile);
     if (!extension_loaded('yaml')) {
         throw new \Xajax\Exception\Config\Yaml('install');
     }
     if (!is_readable($sConfigFile)) {
         throw new \Xajax\Exception\Config\File('access', $sConfigFile);
     }
     $aConfigOptions = yaml_parse_file($sConfigFile);
     if (!is_array($aConfigOptions)) {
         throw new \Xajax\Exception\Config\File('content', $sConfigFile);
     }
     // Content read from config file. Try to parse.
     Config::setOptions($aConfigOptions, $sKey);
 }