You are here

protected function TypedConfigManager::alterDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/TypedConfigManager.php \Drupal\Core\Config\TypedConfigManager::alterDefinitions()

Invokes the hook to alter the definitions if the alter hook is set.

Parameters

$definitions: The discovered plugin definitions.

Overrides DefaultPluginManager::alterDefinitions

File

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

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