function DesignToken::__construct
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Theme/DesignToken/DesignToken.php \Drupal\Core\Theme\DesignToken\DesignToken::__construct()
Construct a DTCG token.
Parameters
string $provider: The Drupal extension providing the token.
string $name: The token's machine name.
\Drupal\Core\Theme\DesignToken\DesignTokenValueInterface $value: The token value.
?\Drupal\Core\Theme\DesignToken\Group $parent: The parent group.
?\Drupal\Core\StringTranslation\TranslatableMarkup $description: A plain text description explaining the token's purpose.
?string $type: The token type if present.
File
-
core/
lib/ Drupal/ Core/ Theme/ DesignToken/ DesignToken.php, line 39
Class
- DesignToken
- A token: distinguishable by containing a $value property.
Namespace
Drupal\Core\Theme\DesignTokenCode
public function __construct(string $provider, public readonly string $name, public readonly DesignTokenValueInterface $value, public readonly ?Group $parent = NULL, public readonly ?TranslatableMarkup $description = NULL, ?string $type = NULL) {
$this->type = $type ?? $parent->type ?? NULL;
$this->provider = $provider;
// Spaces are allowed path but not for plugin IDs.
$this->id = \strtr($this->getPath(), [
' ' => '_',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.