1 | <?php |
||
10 | class GraphQLLanguageContext { |
||
11 | |||
12 | /** |
||
13 | * Indicates if the GraphQL context language is currently active. |
||
14 | * |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected $isActive; |
||
18 | |||
19 | /** |
||
20 | * The current language context. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $currentLanguage; |
||
25 | |||
26 | /** |
||
27 | * The language manager service. |
||
28 | * |
||
29 | * @var \Drupal\Core\Language\LanguageManagerInterface |
||
30 | */ |
||
31 | protected $languageManager; |
||
32 | |||
33 | /** |
||
34 | * GraphQLLanguageContext constructor. |
||
35 | * |
||
36 | * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager |
||
37 | * The language manager service. |
||
38 | */ |
||
39 | public function __construct(LanguageManagerInterface $languageManager) { |
||
42 | |||
43 | /** |
||
44 | * Retrieve the current language. |
||
45 | * |
||
46 | * @return string|null |
||
47 | * The current language code, or null if the context is not active. |
||
48 | */ |
||
49 | public function getCurrentLanguage() { |
||
54 | |||
55 | /** |
||
56 | * Executes a callable in a defined language context. |
||
57 | * |
||
58 | * @param callable $callable |
||
59 | * The callable to be executed. |
||
60 | * @param string $language |
||
61 | * The langcode to be set. |
||
62 | * |
||
63 | * @return mixed |
||
64 | * The callables result. |
||
65 | * |
||
66 | * @throws \Exception |
||
67 | * Any exception caught while executing the callable. |
||
68 | */ |
||
69 | public function executeInLanguageContext(callable $callable, $language) { |
||
87 | |||
88 | } |
||
89 |