comparison core/lib/Drupal/Core/Language/LanguageManagerInterface.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core\Language;
4
5 use Drupal\Core\Url;
6
7 /**
8 * Common interface for the language manager service.
9 */
10 interface LanguageManagerInterface {
11
12 /**
13 * Returns whether or not the site has more than one language added.
14 *
15 * @return bool
16 * TRUE if more than one language is added, FALSE otherwise.
17 */
18 public function isMultilingual();
19
20 /**
21 * Returns an array of the available language types.
22 *
23 * @return array
24 * An array of language type machine names.
25 */
26 public function getLanguageTypes();
27
28 /**
29 * Returns information about all defined language types.
30 *
31 * @return array
32 * An associative array of language type information arrays keyed by
33 * language type machine name, in the format of
34 * hook_language_types_info(). In some implementing classes, this is based
35 * on information from hook_language_types_info() and
36 * hook_language_types_info_alter().
37 */
38 public function getDefinedLanguageTypesInfo();
39
40 /**
41 * Returns the current language for the given type.
42 *
43 * @param string $type
44 * (optional) The language type; e.g., the interface or the content
45 * language. Defaults to
46 * \Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE.
47 *
48 * @return \Drupal\Core\Language\LanguageInterface
49 * The current language object for the given type of language.
50 */
51 public function getCurrentLanguage($type = LanguageInterface::TYPE_INTERFACE);
52
53 /**
54 * Resets the given language type or all types if none specified.
55 *
56 * @param string|null $type
57 * (optional) The language type to reset as a string, e.g.,
58 * LanguageInterface::TYPE_INTERFACE, or NULL to reset all language types.
59 * Defaults to NULL.
60 *
61 * @return \Drupal\Core\Language\LanguageManagerInterface
62 * The language manager that has been reset.
63 */
64 public function reset($type = NULL);
65
66 /**
67 * Returns a language object representing the site's default language.
68 *
69 * @return \Drupal\Core\Language\LanguageInterface
70 * A language object.
71 */
72 public function getDefaultLanguage();
73
74 /**
75 * Returns a list of languages set up on the site.
76 *
77 * @param int $flags
78 * (optional) Specifies the state of the languages that have to be returned.
79 * It can be: LanguageInterface::STATE_CONFIGURABLE,
80 * LanguageInterface::STATE_LOCKED, or LanguageInterface::STATE_ALL.
81 *
82 * @return \Drupal\Core\Language\LanguageInterface[]
83 * An associative array of languages, keyed by the language code.
84 */
85 public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE);
86
87 /**
88 * Returns a list of languages set up on the site in their native form.
89 *
90 * @return \Drupal\Core\Language\LanguageInterface[]
91 * An associative array of languages, keyed by the language code, ordered
92 * by weight ascending and name ascending.
93 */
94 public function getNativeLanguages();
95
96 /**
97 * Returns a language object from the given language code.
98 *
99 * @param string $langcode
100 * The language code.
101 *
102 * @return \Drupal\core\Language\LanguageInterface|null
103 * A fully-populated language object or NULL.
104 */
105 public function getLanguage($langcode);
106
107 /**
108 * Produced the printed name for a language for display.
109 *
110 * @param string $langcode
111 * The language code.
112 *
113 * @return string
114 * The printed name of the language.
115 */
116 public function getLanguageName($langcode);
117
118 /**
119 * Returns a list of the default locked languages.
120 *
121 * @param int $weight
122 * (optional) An integer value that is used as the start value for the
123 * weights of the locked languages.
124 *
125 * @return \Drupal\Core\Language\LanguageInterface[]
126 * An array of language objects.
127 */
128 public function getDefaultLockedLanguages($weight = 0);
129
130 /**
131 * Checks whether a language is locked.
132 *
133 * @param string $langcode
134 * The language code.
135 *
136 * @return bool
137 * Returns whether the language is locked.
138 */
139 public function isLanguageLocked($langcode);
140
141 /**
142 * Returns the language fallback candidates for a given context.
143 *
144 * @param array $context
145 * (optional) An associative array of data that can be useful to determine
146 * the fallback sequence. The following keys are used in core:
147 * - langcode: Language code of the desired language.
148 * - operation: The name of the operation indicating the context where
149 * language fallback is being applied. The following operations are
150 * defined in core, but more may be defined in contributed modules:
151 * - entity_view: Invoked when an entity is about to be displayed.
152 * The data key contains the loaded entity.
153 * - views_query: Invoked when a field based views query is performed.
154 * The data key contains a reference to the field object.
155 * - locale_lookup: Invoked when a string translation was not found.
156 * The data key contains the source string.
157 * - data: A data structure that makes sense in the provided
158 * context, see above.
159 *
160 * @return array
161 * An array of language codes sorted by priority: first values should be
162 * tried first.
163 */
164 public function getFallbackCandidates(array $context = []);
165
166 /**
167 * Returns the language switch links for the given language type.
168 *
169 * @param string $type
170 * The language type.
171 * @param \Drupal\Core\Url $url
172 * The URL the switch links will be relative to.
173 *
174 * @return array
175 * A keyed array of links ready to be themed.
176 */
177 public function getLanguageSwitchLinks($type, Url $url);
178
179 /**
180 * Sets the configuration override language.
181 *
182 * @param \Drupal\Core\Language\LanguageInterface $language
183 * The language to override configuration with.
184 *
185 * @return $this
186 */
187 public function setConfigOverrideLanguage(LanguageInterface $language = NULL);
188
189 /**
190 * Gets the current configuration override language.
191 *
192 * @return \Drupal\Core\Language\LanguageInterface
193 * The current configuration override language.
194 */
195 public function getConfigOverrideLanguage();
196
197 /**
198 * Some common languages with their English and native names.
199 *
200 * Language codes are defined by the W3C language tags document for
201 * interoperability. Language codes typically have a language and, optionally,
202 * a script or regional variant name. See:
203 * http://www.w3.org/International/articles/language-tags/ for more
204 * information.
205 *
206 * @return array
207 * An array of language code to language name information. Language name
208 * information itself is an array of English and native names.
209 */
210 public static function getStandardLanguageList();
211
212 }