public function TypedConfigManager::create

Overrides \Drupal\Core\TypedData\TypedDataManager::create()

Fills in default type and does variable replacement.

Overrides TypedDataManager::create

1 call to TypedConfigManager::create()
TypedConfigManager::get in drupal/core/lib/Drupal/Core/Config/TypedConfigManager.php
Gets typed configuration data.

File

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

Class

TypedConfigManager
Manages config type plugins.

Namespace

Drupal\Core\Config

Code

public function create(array $definition, $value = NULL, $name = NULL, $parent = NULL) {
  if (!isset($definition['type'])) {

    // Set default type 'string' if possible. If not it will be 'undefined'.
    if (is_string($value)) {
      $definition['type'] = 'string';
    }
    else {
      $definition['type'] = 'undefined';
    }
  }
  elseif (strpos($definition['type'], ']')) {

    // Replace variable names in definition.
    $replace = is_array($value) ? $value : array();
    if (isset($parent)) {
      $replace['%parent'] = $parent
        ->getValue();
    }
    if (isset($name)) {
      $replace['%key'] = $name;
    }
    $definition['type'] = $this
      ->replaceName($definition['type'], $replace);
  }

  // Create typed config object.
  return parent::create($definition, $value, $name, $parent);
}