public TypedConfigManager::buildDataDefinition(array $definition, $value, $name = NULL, $parent = NULL)
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.
Parameters
array $definition: The base type definition array, for which a data definition should be created.
$value: Optional value of the configuration element.
string $name: Optional name of the configuration element.
object $parent: Optional parent element.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface A data definition for the given data type.
Overrides TypedConfigManagerInterface::buildDataDefinition
File
- core/lib/Drupal/Core/Config/TypedConfigManager.php, line 80
Class
- TypedConfigManager
- Manages config schema type plugins.
Namespace
Drupal\Core\Config
Code
public function buildDataDefinition(array $definition, $value, $name = NULL, $parent = NULL) { // Add default values for data type and replace variables. $definition += array('type' => 'undefined'); $replace = []; $type = $definition['type']; if (strpos($type, ']')) { // Replace variable names in definition. $replace = is_array($value) ? $value : array(); if (isset($parent)) { $replace['%parent'] = $parent; } if (isset($name)) { $replace['%key'] = $name; } $type = $this->replaceName($type, $replace); // Remove the type from the definition so that it is replaced with the // concrete type from schema definitions. unset($definition['type']); } // Add default values from type definition. $definition += $this->getDefinitionWithReplacements($type, $replace); $data_definition = $this->createDataDefinition($definition['type']); // Pass remaining values from definition array to data definition. foreach ($definition as $key => $value) { if (!isset($data_definition[$key])) { $data_definition[$key] = $value; } } return $data_definition; }
Please login to continue.