W3cubDocs

/Drupal 8

protected function TypedConfigManager::getDefinitionWithReplacements

protected TypedConfigManager::getDefinitionWithReplacements($base_plugin_id, array $replacements, $exception_on_invalid = TRUE)

Gets a schema definition with replacements for dynamic names.

Parameters

string $base_plugin_id: A plugin ID.

array $replacements: An array of replacements for dynamic type names.

bool $exception_on_invalid: (optional) This parameter is passed along to self::getDefinition(). However, self::getDefinition() does not respect this parameter, so it is effectively useless in this context.

Return value

array A schema definition array.

File

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

Class

TypedConfigManager
Manages config schema type plugins.

Namespace

Drupal\Core\Config

Code

protected function getDefinitionWithReplacements($base_plugin_id, array $replacements, $exception_on_invalid = TRUE) {
  $definitions = $this->getDefinitions();
  $type = $this->determineType($base_plugin_id, $definitions);
  $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);

    // Replace dynamic portions of the definition type.
    if (!empty($replacements) && strpos($definition['type'], ']')) {
      $sub_type = $this->determineType($this->replaceName($definition['type'], $replacements), $definitions);
      // Merge the newly determined subtype definition with the original
      // definition.
      $definition = NestedArray::mergeDeepArray([$definitions[$sub_type], $definition], TRUE);
      $type = "$type||$sub_type";
    }
    // 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;
}

© 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::getDefinitionWithReplacements/8.1.x