PatternDefinitionVariant.php in UI Patterns 8
File
src/Definition/PatternDefinitionVariant.php
View source
<?php
namespace Drupal\ui_patterns\Definition;
class PatternDefinitionVariant implements \ArrayAccess {
use ArrayAccessDefinitionTrait;
protected $definition = [
'name' => NULL,
'label' => NULL,
'description' => NULL,
];
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;
}
}
public function toArray() {
return $this->definition;
}
public function getName() {
return $this->definition['name'];
}
public function getLabel() {
return $this->definition['label'];
}
public function getDescription() {
return $this->definition['description'];
}
public function setDescription($description) {
$this->definition['description'] = $description;
return $this;
}
}