class DomainConfigOverride in Domain Site Settings 8
Overrides the config with the saved domain specific settings.
@package Drupal\domain_site_settings
Hierarchy
- class \Drupal\domain_site_settings\Configuration\DomainConfigOverride implements ConfigFactoryOverrideInterface
Expanded class hierarchy of DomainConfigOverride
1 string reference to 'DomainConfigOverride'
1 service uses DomainConfigOverride
File
- src/
Configuration/ DomainConfigOverride.php, line 15
Namespace
Drupal\domain_site_settings\ConfigurationView source
class DomainConfigOverride implements ConfigFactoryOverrideInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a DomainSourcePathProcessor object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The module handler service.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritDoc}
*/
public function loadOverrides($names = []) {
$overrides = [];
if (in_array('system.site', $names)) {
/** @var \Drupal\domain\DomainNegotiator $negotiator */
$negotiator = \Drupal::service('domain.negotiator');
$domain = $negotiator
->getActiveDomain();
if (!empty($domain)) {
$domain_key = $domain
->id();
$configFactory = $this->configFactory
->get('domain_site_settings.domainconfigsettings');
if ($configFactory
->get($domain_key) !== NULL) {
$site_name = $configFactory
->get($domain_key . '.site_name');
$site_slogan = $configFactory
->get($domain_key . '.site_slogan');
$site_mail = $configFactory
->get($domain_key . '.site_mail');
$site_403 = $configFactory
->get($domain_key . '.site_403');
$site_404 = $configFactory
->get($domain_key . '.site_404');
$site_front = $configFactory
->get($domain_key . '.site_frontpage');
$front = $site_front !== \NULL ? $site_front : '/node';
// Create the new settings array to override the configuration.
$overrides['system.site'] = [
'name' => $site_name,
'slogan' => $site_slogan,
'mail' => $site_mail,
'page' => [
'403' => $site_403,
'404' => $site_404,
'front' => $front,
],
];
}
}
}
return $overrides;
}
/**
* {@inheritDoc}
*/
public function getCacheSuffix() {
return 'MultiSiteConfigurationOverrider';
}
/**
* {@inheritDoc}
*/
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
/**
* {@inheritDoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DomainConfigOverride:: |
protected | property | The config factory. | |
DomainConfigOverride:: |
public | function |
Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface:: |
|
DomainConfigOverride:: |
public | function |
Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface:: |
|
DomainConfigOverride:: |
public | function |
The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface:: |
|
DomainConfigOverride:: |
public | function |
Returns config overrides. Overrides ConfigFactoryOverrideInterface:: |
|
DomainConfigOverride:: |
public | function | Constructs a DomainSourcePathProcessor object. |