You are here

public function PatternDefinitionField::__construct in UI Patterns 8

PatternDefinitionField constructor.

File

src/Definition/PatternDefinitionField.php, line 31

Class

PatternDefinitionField
Class PatternDefinitionField.

Namespace

Drupal\ui_patterns\Definition

Code

public function __construct($name, $value) {
  if (is_scalar($value)) {
    $this->definition['name'] = is_numeric($name) ? $value : $name;
    $this->definition['label'] = $value;
  }
  else {
    $this->definition['name'] = !isset($value['name']) ? $name : $value['name'];
    $this->definition['label'] = $value['label'];
    $this->definition = $value + $this->definition;
  }
}