class Config in Domain Access 8
Extend core Config class to save domain specific configuration.
Hierarchy
- class \Drupal\Core\Config\ConfigBase implements RefinableCacheableDependencyInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Config\StorableConfigBase
Expanded class hierarchy of Config
File
- domain_config_ui/
src/ Config/ Config.php, line 11
Namespace
Drupal\domain_config_ui\ConfigView source
class Config extends CoreConfig {
/**
* The Domain config UI manager.
*
* @var \Drupal\domain_config_ui\DomainConfigUIManager
*/
protected $domainConfigUIManager;
/**
* Set the Domain config UI manager.
*
* @param \Drupal\domain_config_ui\DomainConfigUIManager $domain_config_ui_manager
* The Domain config UI manager.
*/
public function setDomainConfigUiManager(DomainConfigUIManager $domain_config_ui_manager) {
$this->domainConfigUIManager = $domain_config_ui_manager;
}
/**
* {@inheritdoc}
*/
public function save($has_trusted_data = FALSE) {
// Remember original config name.
$originalName = $this->name;
try {
// Get domain config name for saving.
$domainConfigName = $this
->getDomainConfigName();
// If config is new and we are saving domain specific configuration,
// save with original name so there is always a default configuration.
if ($this->isNew && $domainConfigName != $originalName) {
parent::save($has_trusted_data);
}
// Switch to use domain config name and save.
$this->name = $domainConfigName;
parent::save($has_trusted_data);
} catch (\Exception $e) {
// Reset back to original config name if save fails and re-throw.
$this->name = $originalName;
throw $e;
}
// Reset back to original config name after saving.
$this->name = $originalName;
return $this;
}
/**
* Get the domain config name.
*/
protected function getDomainConfigName() {
// Return selected config name.
return $this->domainConfigUIManager
->getSelectedConfigName($this->name);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
Config:: |
protected | property | The Domain config UI manager. | |
Config:: |
protected | property | An event dispatcher instance to use for configuration events. | |
Config:: |
protected | property | The current module overrides. | |
Config:: |
protected | property | The current runtime data. | |
Config:: |
protected | property | The current settings overrides. | |
Config:: |
public | function |
Unsets a value in this configuration object. Overrides ConfigBase:: |
1 |
Config:: |
public | function |
Deletes the configuration object. Overrides StorableConfigBase:: |
1 |
Config:: |
public | function |
Gets data from this configuration object. Overrides ConfigBase:: |
|
Config:: |
protected | function | Get the domain config name. | |
Config:: |
public | function | Gets original data from this configuration object. | |
Config:: |
public | function | Gets the raw data without overrides. | |
Config:: |
public | function | Determines if overrides are applied to a key for this configuration object. | |
Config:: |
public | function |
Initializes a configuration object with pre-loaded data. Overrides StorableConfigBase:: |
|
Config:: |
protected | function | Resets the current data, so overrides are re-applied. | |
Config:: |
public | function |
Saves the configuration object. Overrides Config:: |
|
Config:: |
public | function |
Sets a value in this configuration object. Overrides ConfigBase:: |
1 |
Config:: |
public | function |
Replaces the data of this configuration object. Overrides ConfigBase:: |
|
Config:: |
public | function | Set the Domain config UI manager. | |
Config:: |
public | function | Sets module overrides for this configuration object. | |
Config:: |
protected | function | Sets the current data for this configuration object. | |
Config:: |
public | function | Sets settings.php overrides for this configuration object. | |
Config:: |
public | function | Constructs a configuration object. | |
ConfigBase:: |
protected | property | The data of the configuration object. | |
ConfigBase:: |
protected | property | The name of the configuration object. | |
ConfigBase:: |
protected | function | Casts any objects that implement MarkupInterface to string. | |
ConfigBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
ConfigBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
ConfigBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
1 |
ConfigBase:: |
public | function | Returns the name of this configuration object. | |
ConfigBase:: |
constant | The maximum length of a configuration object name. | ||
ConfigBase:: |
public | function | Merges data into a configuration object. | |
ConfigBase:: |
public | function | Sets the name of this configuration object. | |
ConfigBase:: |
protected | function | Validates all keys in a passed in config array structure. | |
ConfigBase:: |
public static | function | Validates the configuration object name. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
StorableConfigBase:: |
protected | property | Whether the configuration object is new or has been saved to the storage. | |
StorableConfigBase:: |
protected | property | The data of the configuration object. | |
StorableConfigBase:: |
protected | property | The config schema wrapper object for this configuration object. | |
StorableConfigBase:: |
protected | property | The storage used to load and save this configuration object. | |
StorableConfigBase:: |
protected | property | The typed config manager. | |
StorableConfigBase:: |
protected | function | Casts the value to correct data type using the configuration schema. | |
StorableConfigBase:: |
protected | function | Gets the schema wrapper for the whole configuration object. | |
StorableConfigBase:: |
public | function | Retrieves the storage used to load and save this configuration object. | |
StorableConfigBase:: |
public | function | Returns whether this configuration object is new. | |
StorableConfigBase:: |
protected | function | Validate the values are allowed data types. |