Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Drupal\graphql\Plugin\GraphQL\DataProducer\Routing;

use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
Expand Down Expand Up @@ -44,6 +46,13 @@ class RouteLoad extends DataProducerPluginBase implements ContainerFactoryPlugin
*/
protected $redirectRepository;

/**
* Language manager for retrieving the default langcode.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;

/**
* {@inheritdoc}
*
Expand All @@ -55,6 +64,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id,
$plugin_definition,
$container->get('path.validator'),
$container->get('language_manager'),
$container->get('redirect.repository', ContainerInterface::NULL_ON_INVALID_REFERENCE)
);
}
Expand All @@ -70,6 +80,8 @@ public static function create(ContainerInterface $container, array $configuratio
* The plugin definition.
* @param \Drupal\Core\Path\PathValidatorInterface $pathValidator
* The path validator service.
* @param \Drupal\Core\Language\LanguageManagerInterface $languageManager
* The language manager.
* @param \Drupal\redirect\RedirectRepository|null $redirectRepository
*
* @codeCoverageIgnore
Expand All @@ -79,10 +91,12 @@ public function __construct(
$pluginId,
$pluginDefinition,
PathValidatorInterface $pathValidator,
LanguageManagerInterface $languageManager,
?RedirectRepository $redirectRepository = NULL
) {
parent::__construct($configuration, $pluginId, $pluginDefinition);
$this->pathValidator = $pathValidator;
$this->languageManager = $languageManager;
$this->redirectRepository = $redirectRepository;
}

Expand All @@ -95,7 +109,8 @@ public function __construct(
* @return \Drupal\Core\Url|null
*/
public function resolve($path, RefinableCacheableDependencyInterface $metadata) {
$redirect = $this->redirectRepository ? $this->redirectRepository->findMatchingRedirect($path, []) : NULL;
$langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
$redirect = $this->redirectRepository ? $this->redirectRepository->findMatchingRedirect($path, [], $langcode) : NULL;
if ($redirect !== NULL) {
$url = $redirect->getRedirectUrl();
}
Expand Down