Interim commit.
[yaffs-website] / web / modules / contrib / token / src / TokenInterface.php
1 <?php
2
3 namespace Drupal\token;
4
5 interface TokenInterface {
6
7   /**
8    * Returns metadata describing supported token types.
9    *
10    * @param $token_type
11    *   The token type for which the metadata is required.
12    *
13    * @return array[]
14    *   An array of token type information from hook_token_info() for the
15    *   specified token type.
16    *
17    * @see hook_token_info()
18    * @see hook_token_info_alter()
19    */
20   public function getTypeInfo($token_type);
21
22   /**
23    * Returns metadata describing supported a token.
24    *
25    * @param $token_type
26    *   The token type for which the metadata is required.
27    * @param $token
28    *   The token name for which the metadata is required.
29    *
30    * @return array[]
31    *   An array of information from hook_token_info() for the specified token.
32    *
33    * @see hook_token_info()
34    * @see hook_token_info_alter()
35    *
36    * @deprecated
37    */
38   public function getTokenInfo($token_type, $token);
39
40   /**
41    * Get a list of token types that can be used without any context (global).
42    *
43    * @return array[]
44    *   An array of global token types.
45    */
46   public function getGlobalTokenTypes();
47
48   /**
49    * Validate an array of tokens based on their token type.
50    *
51    * @param string $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.
55    *
56    * @return string[]
57    *   An array with the invalid tokens in their original raw forms.
58    */
59   function getInvalidTokens($type, $tokens);
60
61   /**
62    * Validate tokens in raw text based on possible contexts.
63    *
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
69    *   performed.
70    *
71    * @return string[]
72    *   An array with the invalid tokens in their original raw forms.
73    */
74   public function getInvalidTokensByContext($value, array $valid_types = []);
75 }