You are here

public function TypedConfigManager::getDefinition in Zircon Profile 8.0

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

Gets a specific plugin definition.

Parameters

string $plugin_id: A plugin id.

bool $exception_on_invalid: Ignored with TypedConfigManagerInterface. Kept for compatibility with DiscoveryInterface.

Return value

array A plugin definition array. If the given plugin id does not have typed configuration definition assigned, the definition of an undefined element type is returned.

Overrides DiscoveryCachedTrait::getDefinition

3 calls to TypedConfigManager::getDefinition()
TypedConfigManager::buildDataDefinition in core/lib/Drupal/Core/Config/TypedConfigManager.php
Creates a new data definition object from a type definition array and actual configuration data. Since type definitions may contain variables to be replaced, we need the configuration value to create it.
TypedConfigManager::get in core/lib/Drupal/Core/Config/TypedConfigManager.php
Gets typed configuration data.
TypedConfigManager::hasConfigSchema in core/lib/Drupal/Core/Config/TypedConfigManager.php
Checks if the configuration schema with the given config name exists.

File

core/lib/Drupal/Core/Config/TypedConfigManager.php, line 121
Contains \Drupal\Core\Config\TypedConfigManager.

Class

TypedConfigManager
Manages config schema type plugins.

Namespace

Drupal\Core\Config

Code

public function getDefinition($base_plugin_id, $exception_on_invalid = TRUE) {
  $definitions = $this
    ->getDefinitions();
  if (isset($definitions[$base_plugin_id])) {
    $type = $base_plugin_id;
  }
  elseif (strpos($base_plugin_id, '.') && ($name = $this
    ->getFallbackName($base_plugin_id))) {

    // Found a generic name, replacing the last element by '*'.
    $type = $name;
  }
  else {

    // If we don't have definition, return the 'undefined' element.
    $type = 'undefined';
  }
  $definition = $definitions[$type];

  // Check whether this type is an extension of another one and compile it.
  if (isset($definition['type'])) {
    $merge = $this
      ->getDefinition($definition['type'], $exception_on_invalid);

    // Preserve integer keys on merge, so sequence item types can override
    // parent settings as opposed to adding unused second, third, etc. items.
    $definition = NestedArray::mergeDeepArray(array(
      $merge,
      $definition,
    ), TRUE);

    // Unset type so we try the merge only once per type.
    unset($definition['type']);
    $this->definitions[$type] = $definition;
  }

  // Add type and default definition class.
  $definition += array(
    'definition_class' => '\\Drupal\\Core\\TypedData\\DataDefinition',
    'type' => $type,
  );
  return $definition;
}