You are here

public function ConfigSplitManager::singleDeactivate in Configuration Split 2.0.x

Deactivate a split.

Parameters

\Drupal\Core\Config\ImmutableConfig $split: The split config.

bool $exportSplit: Whether to export the split config first.

bool $override: Allows the deactivation via override.

Return value

\Drupal\Core\Config\StorageInterface The storage to pass to a ConfigImporter to do the config changes.

File

src/ConfigSplitManager.php, line 624

Class

ConfigSplitManager
The manager to split and merge.

Namespace

Drupal\config_split

Code

public function singleDeactivate(ImmutableConfig $split, bool $exportSplit = FALSE, $override = FALSE) : StorageInterface {
  if (!$split
    ->get('status') && !$override) {
    throw new \InvalidArgumentException('Split is already not active.');
  }
  $transformation = new MemoryStorage();
  static::replaceStorageContents($this->active, $transformation);
  $preview = $this
    ->getPreviewStorage($split, $transformation);
  if ($preview === NULL) {
    throw new \RuntimeException();
  }
  $this
    ->splitPreview($split, $transformation, $preview);
  if ($exportSplit) {
    $permanent = $this
      ->getSplitStorage($split, $this->sync);
    if ($permanent === NULL) {
      throw new \RuntimeException();
    }
    static::replaceStorageContents($preview, $permanent);
  }

  // Deactivate the split in the transformation so that the importer does it.
  $config = $transformation
    ->read($split
    ->getName());
  if ($config !== FALSE && !$override) {
    $config['status'] = FALSE;
    $transformation
      ->write($split
      ->getName(), $config);
  }
  return $transformation;
}