本文整理匯總了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);
}