class PatternContext in UI Patterns 8
Class PatternContext.
@package Drupal\ui_patterns\Context
Hierarchy
- class \Drupal\ui_patterns\Element\PatternContext
Expanded class hierarchy of PatternContext
6 files declare their use of PatternContext
- ui_patterns.api.php in ./
ui_patterns.api.php - API file.
- ui_patterns.module in ./
ui_patterns.module - Contains ui_patterns.module.
- ui_patterns_ds.module in modules/
ui_patterns_ds/ ui_patterns_ds.module - Contains module file.
- ui_patterns_field_group.module in modules/
ui_patterns_field_group/ ui_patterns_field_group.module - Contains module file.
- ui_patterns_layouts.module in modules/
ui_patterns_layouts/ ui_patterns_layouts.module - Contains module file.
File
- src/
Element/ PatternContext.php, line 10
Namespace
Drupal\ui_patterns\ElementView source
class PatternContext {
/**
* Pattern context type.
*
* @var string
*/
protected $type = '';
/**
* Context properties.
*
* @var array
*/
protected $properties = [];
/**
* PatternContext constructor.
*
* @param string $type
* Pattern context type.
* @param array $values
* Initial context values.
*/
public function __construct($type, array $values = []) {
$this->type = $type;
unset($values['type']);
foreach ($values as $name => $value) {
$this
->setProperty($name, $value);
}
}
/**
* Get pattern context property.
*
* @return mixed
* Property value.
*/
public function getProperty($name) {
return isset($this->properties[$name]) ? $this->properties[$name] : NULL;
}
/**
* Set pattern context property.
*
* @param string $name
* Property name.
* @param mixed $value
* Property value.
*/
public function setProperty($name, $value) {
$this->properties[$name] = $value;
}
/**
* Check whereas the current context is of a given type.
*
* @param string $type
* Type string.
*
* @return bool
* Whereas the current context is of a given type.
*/
public function isOfType($type) {
return $this->type == $type;
}
/**
* Get context type.
*
* @return string
* Context type.
*/
public function getType() {
return $this->type;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PatternContext:: |
protected | property | Context properties. | |
PatternContext:: |
protected | property | Pattern context type. | |
PatternContext:: |
public | function | Get pattern context property. | |
PatternContext:: |
public | function | Get context type. | |
PatternContext:: |
public | function | Check whereas the current context is of a given type. | |
PatternContext:: |
public | function | Set pattern context property. | |
PatternContext:: |
public | function | PatternContext constructor. |