5
5
use Drupal \Core \Cache \CacheableMetadata ;
6
6
use Drupal \Core \Config \ConfigFactoryOverrideInterface ;
7
7
use Drupal \Core \Config \StorageInterface ;
8
+ use Drupal \language \LanguageNegotiationMethodManager ;
8
9
9
10
/**
10
11
* GraphQL config overrides.
@@ -20,28 +21,38 @@ class GraphQLConfigOverrides implements ConfigFactoryOverrideInterface {
20
21
*/
21
22
protected $ baseStorage ;
22
23
24
+ /**
25
+ * The negotiator manager service.
26
+ *
27
+ * @var \Drupal\language\LanguageNegotiationMethodManager
28
+ */
29
+ protected $ negotiatorManager ;
30
+
23
31
/**
24
32
* GraphQLConfigOverrides constructor.
25
33
*
26
34
* @param \Drupal\Core\Config\StorageInterface $storage
27
35
* The config storage service.
28
36
*/
29
- public function __construct (StorageInterface $ storage ) {
37
+ public function __construct (StorageInterface $ storage, LanguageNegotiationMethodManager $ negotiatorManager ) {
30
38
$ this ->baseStorage = $ storage ;
39
+ $ this ->negotiatorManager = $ negotiatorManager ;
31
40
}
32
41
33
42
/**
34
43
* {@inheritdoc}
35
44
*/
36
45
public function loadOverrides ($ names ) {
37
- if (in_array ('language.types ' , $ names )) {
38
- if ($ config = $ this ->baseStorage ->read ('language.types ' )) {
39
- foreach (array_keys ($ config ['negotiation ' ]) as $ type ) {
40
- $ config ['negotiation ' ][$ type ]['enabled ' ]['language-graphql ' ] = -999 ;
41
- asort ($ config ['negotiation ' ][$ type ]['enabled ' ]);
42
- }
43
- return ['language.types ' => $ config ];
46
+ if (
47
+ in_array ('language.types ' , $ names )
48
+ && $ this ->negotiatorManager ->hasDefinition ('language-graphql ' )
49
+ && $ config = $ this ->baseStorage ->read ('language.types ' )
50
+ ) {
51
+ foreach (array_keys ($ config ['negotiation ' ]) as $ type ) {
52
+ $ config ['negotiation ' ][$ type ]['enabled ' ]['language-graphql ' ] = -999 ;
53
+ asort ($ config ['negotiation ' ][$ type ]['enabled ' ]);
44
54
}
55
+ return ['language.types ' => $ config ];
45
56
}
46
57
return [];
47
58
}
0 commit comments