function DesignTokenPluginManager::extractDefinitions

Convert raw plugin definitions from the discovery into a flattened list.

YamlDiscovery doesn't know about the nested groups structure of DTCG and may create a plugin by group instead of a plugin by token.

Parameters

array $discovered: The raw plugin definitions from the discovery.

Return value

array The extracted definitions.

File

core/lib/Drupal/Core/Theme/DesignToken/DesignTokenPluginManager.php, line 79

Class

DesignTokenPluginManager
Defines a design tokens plugin manager.

Namespace

Drupal\Core\Theme\DesignToken

Code

protected function extractDefinitions(array $discovered) : array {
  $definitions = [];
  foreach ($discovered as $id => $data) {
    // Id & provider have been automatically added by YamlDiscovery.
    unset($data['id']);
    $provider = $data['provider'];
    unset($data['provider']);
    $tree = $this->parseDtcg($provider, $id, $data);
    $definitions += $this->flattenDefinitions($tree);
  }
  return $definitions;
}

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