You are here

public function PatternDefinitionSetting::__construct in UI Patterns Settings 8

Same name and namespace in other branches
  1. 8.2 src/Definition/PatternDefinitionSetting.php \Drupal\ui_patterns_settings\Definition\PatternDefinitionSetting::__construct()

PatternDefinitionSetting constructor.

File

src/Definition/PatternDefinitionSetting.php, line 36

Class

PatternDefinitionSetting
Class PatternDefinitionSetting.

Namespace

Drupal\ui_patterns_settings\Definition

Code

public function __construct($name, $value) {
  if (is_scalar($value)) {
    $this->definition['name'] = is_numeric($name) ? $value : $name;
    $this->definition['label'] = $value;
    $this->definition['type'] = 'textfield';
    $this->definition['preview'] = NULL;
  }
  else {
    $this->definition['name'] = !isset($value['name']) ? $name : $value['name'];
    $this->definition['label'] = $value['label'];
    $this->definition['required'] = isset($value['required']) ? $value['required'] : FALSE;
    $this->definition['default_value'] = isset($value['default_value']) ? $value['default_value'] : NULL;
    $this->definition['preview'] = isset($value['preview']) ? $value['preview'] : NULL;
    $this->definition['options'] = isset($value['options']) ? $value['options'] : NULL;
    $this->definition = $value + $this->definition;
  }
}