class ColorData in Color API 8
Provides the Color Typed Data type.
This data type is a wrapper for colors. It has the following properties:
- hexadecimal: A Simple Data hexadecimal_color object holding the color in the format #XXXXXX, where X is a hexadecimal character (0-9 or a-f).
- rgb: A complex data object with the properties:
- red: an integer with a value between 0 and 255.
- green: an integer with a value between 0 and 255.
- blue: an integer with a value between 0 and 255.
Plugin annotation
@DataType(
id = "colorapi_color",
label = @Translation("Color"),
description = @Translation("A Complex Data object containing a color in hexadecimal and RGB formats"),
definition_class = "\Drupal\colorapi\TypedData\Definition\ColorDataDefinition"
)
Hierarchy
- class \Drupal\Core\TypedData\TypedData implements PluginInspectionInterface, TypedDataInterface uses DependencySerializationTrait, StringTranslationTrait, TypedDataTrait
- class \Drupal\Core\TypedData\Plugin\DataType\Map implements \Drupal\Core\TypedData\Plugin\DataType\IteratorAggregate, ComplexDataInterface
- class \Drupal\colorapi\Plugin\DataType\ColorData implements ColorInterface
- class \Drupal\Core\TypedData\Plugin\DataType\Map implements \Drupal\Core\TypedData\Plugin\DataType\IteratorAggregate, ComplexDataInterface
Expanded class hierarchy of ColorData
1 string reference to 'ColorData'
- colorapi.data_types.schema.yml in config/
schema/ colorapi.data_types.schema.yml - config/schema/colorapi.data_types.schema.yml
File
- src/
Plugin/ DataType/ ColorData.php, line 25
Namespace
Drupal\colorapi\Plugin\DataTypeView source
class ColorData extends Map implements ColorInterface {
/**
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE) {
$this
->setHexadecimal($values['hexadecimal'], $notify);
$this
->setRgb($values['rgb'], $notify);
}
/**
* {@inheritdoc}
*/
public function getValue() {
return $this
->getHexadecimal();
}
/**
* {@inheritdoc}
*/
public function setHexadecimal($color, $notify = TRUE) {
$this
->get('hexadecimal')
->setValue($color, $notify);
}
/**
* {@inheritdoc}
*/
public function getHexadecimal() {
return $this
->get('hexadecimal')
->getValue();
}
/**
* {@inheritdoc}
*/
public function setRgb(array $rgb, $notify = TRUE) {
$this
->get('rgb')
->setValue($rgb, $notify);
}
/**
* {@inheritdoc}
*/
public function getRgb() {
return $this
->get('rgb')
->getValue();
}
/**
* {@inheritdoc}
*/
public function setRed($red, $notify = TRUE) {
$this
->get('rgb')
->setRed($red, $notify);
}
/**
* {@inheritdoc}
*/
public function getRed() {
return $this
->get('rgb')
->getRed();
}
/**
* {@inheritdoc}
*/
public function setGreen($green, $notify = TRUE) {
$this
->get('rgb')
->setGreen($green, $notify);
}
/**
* {@inheritdoc}
*/
public function getGreen() {
return $this
->get('rgb')
->getGreen();
}
/**
* {@inheritdoc}
*/
public function setBlue($blue, $notify = TRUE) {
$this
->get('rgb')
->setBlue($blue, $notify);
}
/**
* {@inheritdoc}
*/
public function getBlue() {
return $this
->get('rgb')
->getBlue();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ColorData:: |
public | function |
Retrieve 'Blue' value of the Color data object RGB property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Retrieve 'Green' value of the Color data object RGB property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Retrieve the hexadecimal color string representation of the color. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Retrieve 'Red' value of the Color data object RGB property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Retrieve RGB value array of the Color data ojbect.. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Gets the data value. Overrides Map:: |
|
ColorData:: |
public | function |
Set 'blue' property of the Color Data's 'RGB' property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Set 'green' property of the Color Data's 'RGB' property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Set the 'hexadecimal' property of the Color Data. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Set 'red' property of the Color Data's 'RGB' property. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Set the 'rgb' property of the Color Data. Overrides ColorInterface:: |
|
ColorData:: |
public | function |
Overrides \Drupal\Core\TypedData\TypedData::setValue(). Overrides Map:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
Map:: |
protected | property |
The data definition. Overrides TypedData:: |
|
Map:: |
protected | property | The array of properties. | |
Map:: |
protected | property | An array of values for the contained properties. | |
Map:: |
public | function |
Applies the default value. Overrides TypedData:: |
4 |
Map:: |
public | function |
Gets a property object. Overrides ComplexDataInterface:: |
|
Map:: |
public | function | ||
Map:: |
public | function |
Gets an array of property objects. Overrides ComplexDataInterface:: |
|
Map:: |
public | function |
Returns a string representation of the data. Overrides TypedData:: |
|
Map:: |
public | function |
Determines whether the data structure is empty. Overrides ComplexDataInterface:: |
17 |
Map:: |
public | function |
Overrides TraversableTypedDataInterface:: |
4 |
Map:: |
public | function |
Sets a property value. Overrides ComplexDataInterface:: |
|
Map:: |
public | function |
Returns an array of all property values. Overrides ComplexDataInterface:: |
1 |
Map:: |
protected | function | Writes the value of a property without handling changes. | 1 |
Map:: |
public | function | Magic method: Implements a deep clone. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TypedData:: |
protected | property | The property name. | |
TypedData:: |
protected | property | The parent typed data object. | |
TypedData:: |
public static | function |
Constructs a TypedData object given its definition and context. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Gets a list of validation constraints. Overrides TypedDataInterface:: |
9 |
TypedData:: |
public | function |
Gets the data definition. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the name of a property or item. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the parent data structure; i.e. either complex data or a list. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
TypedData:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
TypedData:: |
public | function |
Returns the property path of the data. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Returns the root of the typed data tree. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Sets the context of a property or item via a context aware parent. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function |
Validates the currently set data value. Overrides TypedDataInterface:: |
|
TypedData:: |
public | function | Constructs a TypedData object given its definition and context. | 3 |
TypedDataTrait:: |
protected | property | The typed data manager used for creating the data types. | |
TypedDataTrait:: |
public | function | Gets the typed data manager. | 2 |
TypedDataTrait:: |
public | function | Sets the typed data manager. | 2 |