function Mapping::__construct

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Config/Schema/Mapping.php \Drupal\Core\Config\Schema\Mapping::__construct()

Overrides TypedData::__construct

File

core/lib/Drupal/Core/Config/Schema/Mapping.php, line 28

Class

Mapping
Defines a mapping configuration element.

Namespace

Drupal\Core\Config\Schema

Code

public function __construct(DataDefinitionInterface $definition, $name = NULL, ?TypedDataInterface $parent = NULL) {
    assert($definition instanceof MapDataDefinition);
    // Validate basic structure.
    foreach ($definition['mapping'] as $key => $key_definition) {
        // Guide developers when a config schema definition is wrong.
        if (!is_array($key_definition)) {
            if (!$parent) {
                throw new \LogicException(sprintf("The mapping definition at `%s` is invalid: its `%s` key contains a %s. It must be an array.", $name, $key, gettype($key_definition)));
            }
            else {
                throw new \LogicException(sprintf("The mapping definition at `%s:%s` is invalid: its `%s` key contains a %s. It must be an array.", $parent->getPropertyPath(), $name, $key, gettype($key_definition)));
            }
        }
    }
    $this->processRequiredKeyFlags($definition);
    parent::__construct($definition, $name, $parent);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.