class Group
A group: distinguishable by not having a $value property.
Hierarchy
- class \Drupal\Core\Theme\DesignToken\Group implements \Drupal\Core\Theme\DesignToken\DtcgInterface
Expanded class hierarchy of Group
3 files declare their use of Group
- DesignTokenPluginManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ DesignTokenPluginManagerTest.php - DesignTokenTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ DesignTokenTest.php - GroupTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ GroupTest.php
260 string references to 'Group'
- AnnotatedClassDiscoveryTest::provideBadAnnotations in core/
tests/ Drupal/ Tests/ Component/ Plugin/ Discovery/ AnnotatedClassDiscoveryTest.php - All the Drupal documentation standards tags.
- BlockContentEntityReferenceSelectionTest::fieldConditionProvider in core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentEntityReferenceSelectionTest.php - Provides possible fields and condition types.
- ClaroFormHooks::formAlter in core/
themes/ claro/ src/ Hook/ ClaroFormHooks.php - Implements hook_form_alter().
- ConfigTargetTest::providerTestFromFormException in core/
tests/ Drupal/ Tests/ Core/ Form/ ConfigTargetTest.php - ConfigTargetTest::testFromFormString in core/
tests/ Drupal/ Tests/ Core/ Form/ ConfigTargetTest.php - Tests from form string.
File
-
core/
lib/ Drupal/ Core/ Theme/ DesignToken/ Group.php, line 13
Namespace
Drupal\Core\Theme\DesignTokenView source
class Group implements DtcgInterface {
/**
* DTCG: $type.
*
* Actual data type which ensures consistency, validation, and tool
* compatibility across platforms.
*/
public readonly ?string $type;
/**
* Construct a DTCG group.
*
* @param string $provider
* The Drupal extension providing the group.
* @param string $name
* The group's machine name.
* @param \Drupal\Core\Theme\DesignToken\DtcgInterface[] $children
* The children (groups or tokens).
* @param ?\Drupal\Core\Theme\DesignToken\Group $parent
* The parent group. Groups can be nested.
* @param ?\Drupal\Core\StringTranslation\TranslatableMarkup $description
* A plain text description explaining the group's purpose.
* @param ?string $type
* The group type if present.
*/
public function __construct(public readonly string $provider, public readonly string $name, protected array $children = [], public readonly ?Group $parent = NULL, public readonly ?TranslatableMarkup $description = NULL, ?string $type = NULL) {
$this->type = $type ?? $parent->type ?? NULL;
assert(Inspector::assertAllObjects($children, DtcgInterface::class));
}
/**
* {@inheritdoc}
*/
public function getType() : ?string {
return $this->type;
}
/**
* {@inheritdoc}
*/
public function getPath() : string {
return $this->parent ? $this->parent
->getPath() . '.' . $this->name : $this->name;
}
/**
* The group's children.
*
* @return array
* The group's children.
*/
public function getChildren() : array {
return $this->children;
}
/**
* Sets the group children.
*
* @param \Drupal\Core\Theme\DesignToken\DtcgInterface[] $children
* The children to set.
*
* @return $this
* The group object.
*/
public function setChildren(array $children) : static {
assert(Inspector::assertAllObjects($children, DtcgInterface::class));
$this->children = $children;
return $this;
}
/**
* {@inheritdoc}
*/
public function toDtcg() : array {
$data = [];
if ($this->type) {
$data['$type'] = $this->type;
}
if ($this->description) {
$data['$description'] = $this->description
->render();
}
foreach ($this->children as $key => $child) {
$data[$key] = $child->toDtcg();
}
return $data;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.