original_string: protected function _configWrite($key, $value, $merge = false)
      {
          if (is_string($key) && $value === null) {
              $this->_configDelete($key);
  
              return;
          }
  
          if ($merge) {
              $update = is_array($key) ? $key : [$key => $value];
              if ($merge === 'shallow') {
                  $this->_config = array_merge($this->_config, Hash::expand($update));
              } else {
                  $this->_config = Hash::merge($this->_config, Hash::expand($update));
              }
  
              return;
          }
  
          if (is_array($key)) {
              foreach ($key as $k => $val) {
                  $this->_configWrite($k, $val);
              }
  
              return;
          }
  
          if (strpos($key, '.') === false) {
              $this->_config[$key] = $value;
  
              return;
          }
  
          $update =& $this->_config;
          $stack = explode('.', $key);
  
          foreach ($stack as $k) {
              if (!is_array($update)) {
                  throw new Exception(sprintf('Cannot set %s value', $key));
              }
  
              if (!isset($update[$k])) {
                  $update[$k] = [];
              }
  
              $update =& $update[$k];
          }
  
          $update = $value;
      }
code: protected function _configWrite($key, $value, $merge = false)
      {
          if (is_string($key) && $value === null) {
              $this->_configDelete($key);
  
              return;
          }
  
          if ($merge) {
              $update = is_array($key) ? $key : [$key => $value];
              if ($merge === 'shallow') {
                  $this->_config = array_merge($this->_config, Hash::expand($update));
              } else {
                  $this->_config = Hash::merge($this->_config, Hash::expand($update));
              }
  
              return;
          }
  
          if (is_array($key)) {
              foreach ($key as $k => $val) {
                  $this->_configWrite($k, $val);
              }
  
              return;
          }
  
          if (strpos($key, '.') === false) {
              $this->_config[$key] = $value;
  
              return;
          }
  
          $update =& $this->_config;
          $stack = explode('.', $key);
  
          foreach ($stack as $k) {
              if (!is_array($update)) {
                  throw new Exception(sprintf('Cannot set %s value', $key));
              }
  
              if (!isset($update[$k])) {
                  $update[$k] = [];
              }
  
              $update =& $update[$k];
          }
  
          $update = $value;
      }
code_tokens: protected function _configWrite ( $ key , $ value , $ merge = false ) { if ( is_string ( $ key ) && $ value === null ) { $ this -> _configDelete ( $ key ) ; return ; } if ( $ merge ) { $ update = is_array ( $ key ) ? $ key : [ $ key => $ value ] ; if ( $ merge === 'shallow' ) { $ this -> _config = array_merge ( $ this -> _config , Hash :: expand ( $ update ) ) ; } else { $ this -> _config = Hash :: merge ( $ this -> _config , Hash :: expand ( $ update ) ) ; } return ; } if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ val ) { $ this -> _configWrite ( $ k , $ val ) ; } return ; } if ( strpos ( $ key , '.' ) === false ) { $ this -> _config [ $ key ] = $ value ; return ; } $ update = & $ this -> _config ; $ stack = explode ( '.' , $ key ) ; foreach ( $ stack as $ k ) { if ( ! is_array ( $ update ) ) { throw new Exception ( sprintf ( 'Cannot set %s value' , $ key ) ) ; } if ( ! isset ( $ update [ $ k ] ) ) { $ update [ $ k ] = [ ] ; } $ update = & $ update [ $ k ] ; } $ update = $ value ; }
docstring: Writes a config key.
  
  @param string|array $key Key to write to.
  @param mixed $value Value to write.
  @param bool|string $merge True to merge recursively, 'shallow' for simple merge,
  false to overwrite, defaults to false.
  @return void
  @throws \Cake\Core\Exception\Exception if attempting to clobber existing config
docstring_tokens: Writes a config key .