本文整理汇总了PHP中Drupal\Core\Config\Config::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::__construct方法的具体用法?PHP Config::__construct怎么用?PHP Config::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Config
的用法示例。
在下文中一共展示了Config::__construct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* {@inheritdoc}
*/
public function __construct(Theme $theme)
{
parent::__construct($theme->getName() . '.settings', \Drupal::service('config.storage'), \Drupal::service('event_dispatcher'), \Drupal::service('config.typed'));
$this->theme = $theme;
// Retrieve cache.
$cache = $theme->getCache('settings');
// Use cached settings.
if ($defaults = $cache->get('defaults')) {
$this->defaults = $defaults;
$this->initWithData($cache->get('data', []));
return;
}
// Retrieve the global settings from configuration.
$this->defaults = \Drupal::config('system.theme.global')->get();
// Retrieve the theme setting plugin discovery defaults (code).
foreach ($theme->getSettingPlugins() as $name => $setting) {
$this->defaults[$name] = $setting->getDefaultValue();
}
// Retrieve the theme ancestry.
$ancestry = $theme->getAncestry();
// Remove the active theme from the ancestry.
$active_theme = array_pop($ancestry);
// Iterate and merge all ancestor theme config into the defaults.
foreach ($ancestry as $ancestor) {
$this->defaults = NestedArray::mergeDeepArray([$this->defaults, $this->getThemeConfig($ancestor)], TRUE);
}
// Merge the active theme config.
$this->initWithData($this->getThemeConfig($active_theme, TRUE));
// Cache the data and defaults.
$cache->set('data', $this->data);
$cache->set('defaults', $this->defaults);
}