You are here

public function MatcherTokensTrait::getAvailableTokens in Linkit 8.4

Same name and namespace in other branches
  1. 8.5 src/MatcherTokensTrait.php \Drupal\linkit\MatcherTokensTrait::getAvailableTokens()

Gets all available tokens.

Parameters

array $types: An array of token types to use.

Return value

array An array with available tokens

1 call to MatcherTokensTrait::getAvailableTokens()
MatcherTokensTrait::insertTokenList in src/MatcherTokensTrait.php
Inserts a form element with a list of available tokens.

File

src/MatcherTokensTrait.php, line 65
Contains \Drupal\linkit\MatcherTokensTrait.

Class

MatcherTokensTrait
Provides friendly methods for matchers using tokens.

Namespace

Drupal\linkit

Code

public function getAvailableTokens(array $types = array()) {
  $info = \Drupal::token()
    ->getInfo();
  $available = array_intersect_key($info['tokens'], array_flip($types));
  return $available;
}