class PatternDefinitionVariant in UI Patterns 8
Class PatternDefinitionVariant.
@package Drupal\ui_patterns\Definition
Hierarchy
- class \Drupal\ui_patterns\Definition\PatternDefinitionVariant implements \Drupal\ui_patterns\Definition\ArrayAccess uses ArrayAccessDefinitionTrait
Expanded class hierarchy of PatternDefinitionVariant
File
- src/
Definition/ PatternDefinitionVariant.php, line 10
Namespace
Drupal\ui_patterns\DefinitionView source
class PatternDefinitionVariant implements \ArrayAccess {
use ArrayAccessDefinitionTrait;
/**
* Default field values.
*
* @var array
*/
protected $definition = [
'name' => NULL,
'label' => NULL,
'description' => NULL,
];
/**
* PatternDefinitionVariant constructor.
*/
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;
}
}
/**
* Return array definition.
*
* @return array
* Array definition.
*/
public function toArray() {
return $this->definition;
}
/**
* Get Name property.
*
* @return mixed
* Property value.
*/
public function getName() {
return $this->definition['name'];
}
/**
* Get Label property.
*
* @return mixed
* Property value.
*/
public function getLabel() {
return $this->definition['label'];
}
/**
* Get Description property.
*
* @return string
* Property value.
*/
public function getDescription() {
return $this->definition['description'];
}
/**
* Set Description property.
*
* @param string $description
* Property value.
*
* @return $this
*/
public function setDescription($description) {
$this->definition['description'] = $description;
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ArrayAccessDefinitionTrait:: |
public | function | ||
ArrayAccessDefinitionTrait:: |
public | function | ||
ArrayAccessDefinitionTrait:: |
public | function | ||
ArrayAccessDefinitionTrait:: |
public | function | ||
PatternDefinitionVariant:: |
protected | property | Default field values. | |
PatternDefinitionVariant:: |
public | function | Get Description property. | |
PatternDefinitionVariant:: |
public | function | Get Label property. | |
PatternDefinitionVariant:: |
public | function | Get Name property. | |
PatternDefinitionVariant:: |
public | function | Set Description property. | |
PatternDefinitionVariant:: |
public | function | Return array definition. | |
PatternDefinitionVariant:: |
public | function | PatternDefinitionVariant constructor. |