You are here

public function TypedDataResolver::getTokensForContexts in Chaos Tool Suite (ctools) 8.3

Extracts an array of tokens and labels.

Parameters

\Drupal\Core\Plugin\Context\ContextInterface[] $contexts: The array of contexts with which we are currently dealing.

Return value

array An array of token keys and corresponding labels.

1 call to TypedDataResolver::getTokensForContexts()
TypedDataResolver::getLabelByToken in src/TypedDataResolver.php
Provides an administrative label for a tokenized relationship.

File

src/TypedDataResolver.php, line 205

Class

TypedDataResolver

Namespace

Drupal\ctools

Code

public function getTokensForContexts($contexts) {
  $tokens = [];
  foreach ($contexts as $context_id => $context) {
    $data_definition = $context
      ->getContextDefinition()
      ->getDataDefinition();
    if ($data_definition instanceof ComplexDataDefinitionInterface) {
      foreach ($this
        ->getTokensFromComplexData($data_definition) as $token => $label) {
        $tokens["{$context_id}:{$token}"] = $data_definition
          ->getLabel() . ': ' . $label;
      }
    }
  }
  return $tokens;
}