class Dimension
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Theme/Plugin/DesignTokenValue/Dimension.php \Drupal\Core\Theme\Plugin\DesignTokenValue\Dimension
Dimension design token value.
Attributes
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase implements \Drupal\Core\Theme\DesignToken\DesignTokenValueInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Theme\Plugin\DesignTokenValue\Dimension extends \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase
- class \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase implements \Drupal\Core\Theme\DesignToken\DesignTokenValueInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Dimension
5 files declare their use of Dimension
- DesignTokenConfigEntityKernelTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - DesignTokenPluginManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ DesignTokenPluginManagerTest.php - DesignTokenValuePluginManagerKernelTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenValuePluginManagerKernelTest.php - DimensionTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ DimensionTest.php - TypographyTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ TypographyTest.php
13 string references to 'Dimension'
- core.design_token_values.schema.yml in core/
config/ schema/ core.design_token_values.schema.yml - core/config/schema/core.design_token_values.schema.yml
- DesignTokenConfigEntityKernelTest::testConfigSchema in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests config schema.
- DesignTokenConfigEntityKernelTest::testPreSave in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests preSave.
- DesignTokenConfigEntityKernelTest::testPreSave in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests preSave.
- DesignTokenConfigEntityKernelTest::testToCss in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests CSS export.
File
-
core/
lib/ Drupal/ Core/ Theme/ Plugin/ DesignTokenValue/ Dimension.php, line 16
Namespace
Drupal\Core\Theme\Plugin\DesignTokenValueView source
class Dimension extends DesignTokenValuePluginBase {
/**
* An integer or floating-point value representing the numeric value.
*/
protected int|float $value;
/**
* Unit of distance.
*/
protected DimensionUnitInterface $unit;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() : array {
return [
'value' => 0,
'unit' => DimensionUnit::Px,
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) : static {
parent::setConfiguration($configuration);
$this->value = $this->configuration['value'];
$this->unit = $this->configuration['unit'] instanceof DimensionUnitInterface ? $this->configuration['unit'] : DimensionUnit::from($this->configuration['unit']);
return $this;
}
/**
* {@inheritdoc}
*/
public function toDtcg() : mixed {
return [
'value' => $this->value,
'unit' => $this->unit->value,
];
}
/**
* {@inheritdoc}
*/
public function toCss() : string {
return $this->value . $this->unit->value;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|
| AutowiredInstanceTrait::createInstanceAutowired | public static | function | Instantiates a new instance of the implementing class using autowiring. | ||
| AutowiredInstanceTrait::getAutowireArguments | private static | function | Resolves arguments for a method using autowiring. | ||
| ConfigurablePluginBase::__construct | public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | Overrides PluginBase::__construct | 6 |
| ConfigurableTrait::$configuration | protected | property | Configuration information passed into the plugin. | ||
| ConfigurableTrait::getConfiguration | public | function | Gets this plugin's configuration. | 3 | |
| DependencySerializationTrait::$_entityStorages | protected | property | An array of entity type IDs keyed by the property name of their storages. | ||
| DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. | ||
| DependencySerializationTrait::__sleep | public | function | 2 | ||
| DependencySerializationTrait::__wakeup | public | function | 2 | ||
| DesignTokenValuePluginBase::prepareConfiguration | public static | function | Prepares configuration for plugin creation. | Overrides DesignTokenValueInterface::prepareConfiguration | |
| Dimension::$unit | protected | property | Unit of distance. | ||
| Dimension::$value | protected | property | An integer or floating-point value representing the numeric value. | ||
| Dimension::defaultConfiguration | public | function | Gets default configuration for this plugin. | Overrides ConfigurableTrait::defaultConfiguration | |
| Dimension::setConfiguration | public | function | Sets the configuration for this plugin instance. | Overrides ConfigurableTrait::setConfiguration | |
| Dimension::toCss | public | function | Exports as CSS value. | Overrides DesignTokenValueInterface::toCss | |
| Dimension::toDtcg | public | function | Exports as DTCG. | Overrides DesignTokenValueInterface::toDtcg | |
| MessengerTrait::$messenger | protected | property | The messenger. | 27 | |
| MessengerTrait::messenger | public | function | Gets the messenger. | 27 | |
| MessengerTrait::setMessenger | public | function | Sets the messenger. | ||
| PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. | 1 | |
| PluginBase::$pluginId | protected | property | The plugin ID. | ||
| PluginBase::create | public static | function | Instantiates a new instance of the implementing class using autowiring. | 70 | |
| PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | |||
| PluginBase::getBaseId | public | function | Gets the base_plugin_id of the plugin instance. | Overrides DerivativeInspectionInterface::getBaseId | |
| PluginBase::getDerivativeId | public | function | Gets the derivative_id of the plugin instance. | Overrides DerivativeInspectionInterface::getDerivativeId | |
| PluginBase::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | Overrides PluginInspectionInterface::getPluginDefinition | 2 |
| PluginBase::getPluginId | public | function | Gets the plugin ID of the plugin instance. | Overrides PluginInspectionInterface::getPluginId | |
| StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
| StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
| StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
| StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
| StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
| StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.