function DesignToken::toDtcg

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Theme/DesignToken/DesignToken.php \Drupal\Core\Theme\DesignToken\DesignToken::toDtcg()

Exports to the DTCG representation.

Return value

array The DTCG representation.

Overrides DtcgInterface::toDtcg

File

core/lib/Drupal/Core/Theme/DesignToken/DesignToken.php, line 70

Class

DesignToken
A token: distinguishable by containing a $value property.

Namespace

Drupal\Core\Theme\DesignToken

Code

public function toDtcg() : array {
  $data = [
    '$type' => $this->type,
    '$value' => $this->value
      ->toDtcg(),
  ];
  if ($this->description) {
    $data['$description'] = $this->description
      ->render();
  }
  return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.