33namespace Drupal \graphql \Plugin \GraphQL \DataProducer \Routing ;
44
55use Drupal \Core \Cache \RefinableCacheableDependencyInterface ;
6+ use Drupal \Core \Language \LanguageInterface ;
7+ use Drupal \Core \Language \LanguageManagerInterface ;
68use Drupal \Core \Path \PathValidatorInterface ;
79use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
810use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
@@ -44,6 +46,13 @@ class RouteLoad extends DataProducerPluginBase implements ContainerFactoryPlugin
4446 */
4547 protected $ redirectRepository ;
4648
49+ /**
50+ * Language manager for retrieving the default langcode.
51+ *
52+ * @var \Drupal\Core\Language\LanguageManagerInterface
53+ */
54+ protected $ languageManager ;
55+
4756 /**
4857 * {@inheritdoc}
4958 *
@@ -55,6 +64,7 @@ public static function create(ContainerInterface $container, array $configuratio
5564 $ plugin_id ,
5665 $ plugin_definition ,
5766 $ container ->get ('path.validator ' ),
67+ $ container ->get ('language_manager ' ),
5868 $ container ->get ('redirect.repository ' , ContainerInterface::NULL_ON_INVALID_REFERENCE )
5969 );
6070 }
@@ -70,6 +80,8 @@ public static function create(ContainerInterface $container, array $configuratio
7080 * The plugin definition.
7181 * @param \Drupal\Core\Path\PathValidatorInterface $pathValidator
7282 * The path validator service.
83+ * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager
84+ * The language manager.
7385 * @param \Drupal\redirect\RedirectRepository|null $redirectRepository
7486 *
7587 * @codeCoverageIgnore
@@ -79,10 +91,12 @@ public function __construct(
7991 $ pluginId ,
8092 $ pluginDefinition ,
8193 PathValidatorInterface $ pathValidator ,
94+ LanguageManagerInterface $ languageManager ,
8295 ?RedirectRepository $ redirectRepository = NULL
8396 ) {
8497 parent ::__construct ($ configuration , $ pluginId , $ pluginDefinition );
8598 $ this ->pathValidator = $ pathValidator ;
99+ $ this ->languageManager = $ languageManager ;
86100 $ this ->redirectRepository = $ redirectRepository ;
87101 }
88102
@@ -95,7 +109,8 @@ public function __construct(
95109 * @return \Drupal\Core\Url|null
96110 */
97111 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 ;
99114 if ($ redirect !== NULL ) {
100115 $ url = $ redirect ->getRedirectUrl ();
101116 }
0 commit comments