Bolt\Config::get PHP Method

get() public method

For example: $var = $config->get('general/wysiwyg/ck/contentsCss');
public get ( string $path, string | array | boolean $default = null ) : mixed
$path string
$default string | array | boolean
return mixed
    public function get($path, $default = null)
    {
        $path = explode('/', $path);
        // Only do something if we get at least one key.
        if (empty($path[0]) || !isset($this->data[$path[0]])) {
            return false;
        }
        $part =& $this->data;
        $value = null;
        foreach ($path as $key) {
            if (!isset($part[$key])) {
                $value = null;
                break;
            }
            $value = $part[$key];
            $part =& $part[$key];
        }
        if ($value !== null) {
            return $value;
        }
        return $default;
    }

Usage Example

 private function loadThemeConfig(Config $config, $theme, $childTheme)
 {
     $themePath = $this->app['resources']->getPath('themebase') . '/' . $theme;
     if (file_exists($themePath)) {
         $configFile = $themePath . '/config.yml';
         // insert parent path right after child path.
         $twigPath = $config->get('twigpath');
         if ($twigPath) {
             $childThemePath = $this->app['resources']->getPath('themebase') . '/' . $childTheme;
             $key = array_search($childThemePath, $twigPath);
             if ($key !== false) {
                 array_splice($twigPath, $key, 1, array($childThemePath, $themePath));
             }
             $config->set('twigpath', $twigPath);
         }
         if (file_exists($configFile)) {
             $themeConfig = self::mergeConfigFile($configFile);
             if ($themeConfig) {
                 // load parent theme config, but without overwriting, because child prevails
                 $config->set('theme', Arr::mergeRecursiveDistinct($themeConfig, $config->get('theme')));
                 // multiple levels allowed
                 if (!empty($themeConfig['parent'])) {
                     $this->loadThemeConfig($config, $themeConfig['parent'], $theme);
                 }
             }
         }
     }
 }
All Usage Examples Of Bolt\Config::get