コード例 #1
0
 /**
  * Write a configuration value
  *
  * @param string $key
  * @param mixed $value
  * @return null
  *
  * @throws zibo\library\config\exception\ConfigException when the provided
  * key is invalid or empty
  */
 public function write($key, $value)
 {
     $this->configIO->write($key, $value);
     if (!$this->isCacheEnabled) {
         return;
     }
     $tokens = explode(Config::TOKEN_SEPARATOR, $key);
     $section = $tokens[0];
     $this->cache->clear($this->cacheType, $section);
 }
コード例 #2
0
ファイル: Config.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Sets a configuration value
  * @param string $key configuration key
  * @param mixed $value value for the configuration key
  * @return null
  * @throws zibo\core\config\exception\ConfigException when the key is empty
  * or not a string
  */
 public function set($key, $value)
 {
     $tokens = $this->getKeyTokens($key);
     $data =& $this->data;
     $numTokens = count($tokens);
     for ($index = 0; $index < $numTokens; $index++) {
         $token = $tokens[$index];
         if ($index == $numTokens - 1) {
             $dataKey = $token;
             break;
         }
         if (isset($data[$token]) && is_array($data[$token])) {
             $data =& $data[$token];
         } else {
             $data[$token] = array();
             $data =& $data[$token];
         }
     }
     $data[$dataKey] = $value;
     $this->io->write($key, $value);
 }