W3cubDocs

/Drupal 8

protected function TypedConfigManager::alterDefinitions

protected TypedConfigManager::alterDefinitions(&$definitions)

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 358

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!TypedConfigManager.php/function/TypedConfigManager::alterDefinitions/8.1.x