Esempio n. 1
0
 /** 
  * Set value(s) in config. 
  * @param use params to move deeper into array 
  * @param last param is the value you want to set 
  * @example set('meta', 'title', 'Great title') - set meta title to 'Great title'
  * @return boolean
  */
 public static function set()
 {
     $keys = func_get_args();
     $config = self::getConfig();
     if (!empty($keys) && !empty($config)) {
         $c =& $config;
         foreach ($keys as $key => $value) {
             if ($key == Data::count($keys) - 1) {
                 $c = $keys[Data::count($keys) - 1];
             } else {
                 if (!isset($c[$value])) {
                     $c[$value] = array();
                 }
                 if (isset($c[$value]) && is_object($c[$value])) {
                     $c[$value] = Format::objectToArray($c[$value]);
                 }
                 $c =& $c[$value];
             }
         }
         $configJson = Format::toJson($config, true);
         if (isset(self::$config)) {
             self::$config = $config;
         }
         if (File::write('../config/custom.config.json', $configJson)) {
             return true;
         }
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Echo JSON and exit. 
  * @param mixed input
  * @param boolean exit after displaying JSON? 
  * @return boolean 
  */
 public static function json($input = false, $exit = true)
 {
     if ($input) {
         echo Format::toJson($input);
         if ($exit) {
             exit;
         }
     }
     return false;
 }