function ConfigManager::uninstall

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::uninstall()
  2. 8.9.x core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::uninstall()
  3. 11.x core/lib/Drupal/Core/Config/ConfigManager.php \Drupal\Core\Config\ConfigManager::uninstall()

File

core/lib/Drupal/Core/Config/ConfigManager.php, line 202

Class

ConfigManager
The ConfigManager provides helper functions for the configuration system.

Namespace

Drupal\Core\Config

Code

public function uninstall($type, $name) {
    $entities = $this->getConfigEntitiesToChangeOnDependencyRemoval($type, [
        $name,
    ], FALSE);
    // Fix all dependent configuration entities.
    
    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
    foreach ($entities['update'] as $entity) {
        $entity->save();
    }
    // Remove all dependent configuration entities.
    foreach ($entities['delete'] as $entity) {
        $entity->setUninstalling(TRUE);
        $entity->delete();
    }
    $config_names = $this->configFactory
        ->listAll($name . '.');
    foreach ($config_names as $config_name) {
        $this->configFactory
            ->getEditable($config_name)
            ->delete();
    }
    // Remove any matching configuration from collections.
    foreach ($this->activeStorage
        ->getAllCollectionNames() as $collection) {
        $collection_storage = $this->activeStorage
            ->createCollection($collection);
        $overrider = $this->getConfigCollectionInfo()
            ->getOverrideService($collection);
        foreach ($collection_storage->listAll($name . '.') as $config_name) {
            if ($overrider) {
                $config = $overrider->createConfigObject($config_name, $collection);
            }
            else {
                $config = new Config($config_name, $collection_storage, $this->eventDispatcher, $this->typedConfigManager);
            }
            $config->initWithData($collection_storage->read($config_name));
            $config->delete();
        }
    }
    $schema_dir = $this->extensionPathResolver
        ->getPath($type, $name) . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY;
    if (is_dir($schema_dir)) {
        // Refresh the schema cache if uninstalling an extension that provides
        // configuration schema.
        $this->typedConfigManager
            ->clearCachedDefinitions();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.