Gdn_ConfigurationSource::get PHP Method

get() public method

Gets a setting from the configuration array. Returns $DefaultValue if the value isn't found.
public get ( string $Name, mixed $DefaultValue = false ) : mixed
$Name string The name of the configuration setting to get. If the setting is contained within an associative array, use dot denomination to get the setting. ie. $this->Get('Database.Host') would retrieve $Configuration[$Group]['Database']['Host'].
$DefaultValue mixed If the parameter is not found in the group, this value will be returned.
return mixed The configuration value.
    public function get($Name, $DefaultValue = false)
    {
        // Shortcut, get the whole config
        if ($Name == '.') {
            return $this->Settings;
        }
        $Keys = explode('.', $Name);
        $KeyCount = count($Keys);
        $Value = $this->Settings;
        for ($i = 0; $i < $KeyCount; ++$i) {
            if (is_array($Value) && array_key_exists($Keys[$i], $Value)) {
                $Value = $Value[$Keys[$i]];
            } else {
                return $DefaultValue;
            }
        }
        if (is_string($Value)) {
            $Result = Gdn_Format::unserialize($Value);
        } else {
            $Result = $Value;
        }
        return $Result;
    }