3 namespace Drupal\token;
5 interface TokenInterface {
8 * Returns metadata describing supported token types.
11 * The token type for which the metadata is required.
14 * An array of token type information from hook_token_info() for the
15 * specified token type.
17 * @see hook_token_info()
18 * @see hook_token_info_alter()
20 public function getTypeInfo($token_type);
23 * Returns metadata describing supported a token.
26 * The token type for which the metadata is required.
28 * The token name for which the metadata is required.
31 * An array of information from hook_token_info() for the specified token.
33 * @see hook_token_info()
34 * @see hook_token_info_alter()
38 public function getTokenInfo($token_type, $token);
41 * Get a list of token types that can be used without any context (global).
44 * An array of global token types.
46 public function getGlobalTokenTypes();
49 * Validate an array of tokens based on their token type.
52 * The type of tokens to validate (e.g. 'node', etc.)
53 * @param string[] $tokens
54 * A keyed array of tokens, and their original raw form in the source text.
57 * An array with the invalid tokens in their original raw forms.
59 function getInvalidTokens($type, $tokens);
62 * Validate tokens in raw text based on possible contexts.
64 * @param string|string[] $value
65 * A string with the raw text containing the raw tokens, or an array of
66 * tokens from token_scan().
67 * @param string[] $valid_types
68 * An array of token types that will be used when token replacement is
72 * An array with the invalid tokens in their original raw forms.
74 public function getInvalidTokensByContext($value, array $valid_types = []);