Exemplo n.º 1
0
 /**
  * Use this to pass a bunch of data at once to the object
  *
  * @param $data , can be an array or a file of the types yaml, json or ini, PHP will be executed!
  * @param bool $override , by default all existing data are replaced
  */
 public static function init($data, $override = true)
 {
     $settingsObj = self::getInstance();
     if (is_string($data)) {
         ob_start();
         include $data;
         switch (FsUtils::getFileExtension($data)) {
             case 'yaml':
             case 'yml':
                 $data = Yaml::parse(ob_get_clean());
                 break;
             case 'json':
                 $data = json_decode(ob_get_clean(), 1);
                 break;
             case 'ini':
                 $data = parse_ini_string(ob_get_clean());
                 break;
         }
     }
     if ($override) {
         $settingsObj->data = $data;
     } else {
         $settingsObj->data = ArrayUtils::arrayMergeRecursiveDistinct($settingsObj->data, $data);
     }
 }