mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Added Config::getPath() and Config::setPath()
This commit is contained in:
parent
e390374c74
commit
7be9ea68c7
@ -248,6 +248,40 @@ class Config{
|
|||||||
return $this->config[$k];
|
return $this->config[$k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function &getPath($path){
|
||||||
|
$currPath =& $this->config;
|
||||||
|
foreach(explode(".", $path) as $component){
|
||||||
|
if(isset($currPath[$component])){
|
||||||
|
$currPath =& $currPath[$component];
|
||||||
|
}else{
|
||||||
|
$currPath = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $currPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function &setPath($path, $value){
|
||||||
|
$currPath =& $this->config;
|
||||||
|
$components = explode(".", $path);
|
||||||
|
$final = array_pop($components);
|
||||||
|
foreach($components as $component){
|
||||||
|
if(!isset($currPath[$component])){
|
||||||
|
$currPath[$component] = array();
|
||||||
|
}
|
||||||
|
$currPath =& $currPath[$component];
|
||||||
|
}
|
||||||
|
$currPath[$final] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $k key to be set
|
* @param string $k key to be set
|
||||||
* @param bool $v value to set key
|
* @param bool $v value to set key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user