You are here

public function Config::save in Domain Access 8

Saves the configuration object.

Must invalidate the cache tags associated with the configuration object.

Parameters

bool $has_trusted_data: Set to TRUE if the configuration data has already been checked to ensure it conforms to schema. Generally this is only used during module and theme installation.

Return value

$this

Overrides Config::save

See also

\Drupal\Core\Config\ConfigInstaller::createConfiguration()

File

domain_config_ui/src/Config/Config.php, line 33

Class

Config
Extend core Config class to save domain specific configuration.

Namespace

Drupal\domain_config_ui\Config

Code

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;
}