Overrides \Drupal\Core\TypedData\TypedDataManager::create()
Fills in default type and does variable replacement.
Overrides TypedDataManager::create
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);
}