3
3
namespace Drupal \graphql \Plugin \GraphQL \DataProducer \Routing ;
4
4
5
5
use Drupal \Core \Cache \RefinableCacheableDependencyInterface ;
6
+ use Drupal \Core \Language \LanguageInterface ;
7
+ use Drupal \Core \Language \LanguageManagerInterface ;
6
8
use Drupal \Core \Path \PathValidatorInterface ;
7
9
use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
8
10
use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
@@ -44,6 +46,13 @@ class RouteLoad extends DataProducerPluginBase implements ContainerFactoryPlugin
44
46
*/
45
47
protected $ redirectRepository ;
46
48
49
+ /**
50
+ * Language manager for retrieving the default langcode.
51
+ *
52
+ * @var \Drupal\Core\Language\LanguageManagerInterface
53
+ */
54
+ protected $ languageManager ;
55
+
47
56
/**
48
57
* {@inheritdoc}
49
58
*
@@ -55,6 +64,7 @@ public static function create(ContainerInterface $container, array $configuratio
55
64
$ plugin_id ,
56
65
$ plugin_definition ,
57
66
$ container ->get ('path.validator ' ),
67
+ $ container ->get ('language_manager ' ),
58
68
$ container ->get ('redirect.repository ' , ContainerInterface::NULL_ON_INVALID_REFERENCE )
59
69
);
60
70
}
@@ -70,6 +80,8 @@ public static function create(ContainerInterface $container, array $configuratio
70
80
* The plugin definition.
71
81
* @param \Drupal\Core\Path\PathValidatorInterface $pathValidator
72
82
* The path validator service.
83
+ * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager
84
+ * The language manager.
73
85
* @param \Drupal\redirect\RedirectRepository|null $redirectRepository
74
86
*
75
87
* @codeCoverageIgnore
@@ -79,10 +91,12 @@ public function __construct(
79
91
$ pluginId ,
80
92
$ pluginDefinition ,
81
93
PathValidatorInterface $ pathValidator ,
94
+ LanguageManagerInterface $ languageManager ,
82
95
?RedirectRepository $ redirectRepository = NULL
83
96
) {
84
97
parent ::__construct ($ configuration , $ pluginId , $ pluginDefinition );
85
98
$ this ->pathValidator = $ pathValidator ;
99
+ $ this ->languageManager = $ languageManager ;
86
100
$ this ->redirectRepository = $ redirectRepository ;
87
101
}
88
102
@@ -95,7 +109,8 @@ public function __construct(
95
109
* @return \Drupal\Core\Url|null
96
110
*/
97
111
public function resolve ($ path , RefinableCacheableDependencyInterface $ metadata ) {
98
- $ redirect = $ this ->redirectRepository ? $ this ->redirectRepository ->findMatchingRedirect ($ path , []) : NULL ;
112
+ $ langcode = $ this ->languageManager ->getCurrentLanguage (LanguageInterface::TYPE_URL )->getId ();
113
+ $ redirect = $ this ->redirectRepository ? $ this ->redirectRepository ->findMatchingRedirect ($ path , [], $ langcode ) : NULL ;
99
114
if ($ redirect !== NULL ) {
100
115
$ url = $ redirect ->getRedirectUrl ();
101
116
}
0 commit comments