} } else { // Throw exception on any non-scalar or non-array value.
if (!
is_array($value)) { throw new UnsupportedDataTypeConfigException("Invalid data type for config element {
$this->
getName()}:
$key"
);
} // Recurse into any nested keys.
foreach ($value as $nested_value_key =>
$nested_value) { $lookup_key =
$key ?
$key . '.' .
$nested_value_key :
$nested_value_key;
$value[$nested_value_key] =
$this->
castValue($lookup_key,
$nested_value);
} // Only sort maps when we have more than 1 element to sort.
if ($element instanceof Mapping &&
count($value) > 1
) { $mapping =
$element->
getDataDefinition()['mapping'
];
if (is_array($mapping)) { // Only sort the keys in $value.
$mapping =
array_intersect_key($mapping,
$value);
// Sort the array in $value using the mapping definition.
$value =
array_replace($mapping,
$value);
} }