/** * Gets a node from the YAML. Can be in Dot.Separated.Syntax * * @param string The name of the node to get * @return BedrockNode */ public function get($setting) { $current = $this->source; $last_key = null; foreach (explode('.', $setting) as $key) { $last_key = $key; if (!isset($current[$key])) { return false; } if (is_array($current[$key])) { $current = $current[$key]; } else { return is_array($current[$key]) ? BedrockNode::create($key, $current[$key], $setting, $this) : $current[$key]; } } return is_array($current) ? BedrockNode::create($last_key, $current, $setting, $this) : $current; }
/** * Gets a member of the {@link $source} array. If $val returns an array, * it returns a new BedrockNode object with that source. This is useful for * daisy-chaining to traverse the configuration. * * If $val returns a string, return the string. * * @param string $val The array key to check in {@link $source} * @return mixed */ public function get($val) { if (is_array($this->source) && isset($this->source[$val])) { $v = $this->source[$val]; if (is_array($v)) { return BedrockNode::create($val, $v, $this->path . "." . $val, $this->topSource); } return $v; } return false; }