function TypedConfigManager::alterDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/TypedConfigManager.php \Drupal\Core\Config\TypedConfigManager::alterDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Config/TypedConfigManager.php \Drupal\Core\Config\TypedConfigManager::alterDefinitions()
  3. 10 core/lib/Drupal/Core/Config/TypedConfigManager.php \Drupal\Core\Config\TypedConfigManager::alterDefinitions()

Overrides DefaultPluginManager::alterDefinitions

File

core/lib/Drupal/Core/Config/TypedConfigManager.php, line 404

Class

TypedConfigManager
Manages config schema type plugins.

Namespace

Drupal\Core\Config

Code

protected function alterDefinitions(&$definitions) {
    $discovered_schema = array_keys($definitions);
    parent::alterDefinitions($definitions);
    $altered_schema = array_keys($definitions);
    if ($discovered_schema != $altered_schema) {
        $added_keys = implode(',', array_diff($altered_schema, $discovered_schema));
        $removed_keys = implode(',', array_diff($discovered_schema, $altered_schema));
        if (!empty($added_keys) && !empty($removed_keys)) {
            $message = "Invoking hook_config_schema_info_alter() has added ({$added_keys}) and removed ({$removed_keys}) schema definitions";
        }
        elseif (!empty($added_keys)) {
            $message = "Invoking hook_config_schema_info_alter() has added ({$added_keys}) schema definitions";
        }
        else {
            $message = "Invoking hook_config_schema_info_alter() has removed ({$removed_keys}) schema definitions";
        }
        throw new ConfigSchemaAlterException($message);
    }
}

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