Skip to content
Snippets Groups Projects

Issue #3486180: Does not support langcode url prefixes more complex than 2...

Open Issue #3486180: Does not support langcode url prefixes more complex than 2...
All threads resolved!
All threads resolved!
Files
10
@@ -2,9 +2,9 @@
namespace Drupal\language_country_negotiation\EventSubscriber;
use Drupal\language_country_negotiation\PathUtility;
use Drupal\language_country_negotiation\Service\CountryManagerInterface;
use Drupal\language_country_negotiation\Service\CurrentCountryInterface;
use Drupal\language_country_negotiation\Service\PathPrefixHelperInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -29,10 +29,13 @@ class CountryEventSubscriber implements EventSubscriberInterface {
* The country manager.
* @param \Drupal\language_country_negotiation\Service\CurrentCountryInterface $currentCountry
* The current country service.
* @param \Drupal\language_country_negotiation\Service\PathPrefixHelperInterface $pathPrefixHelper
* The path prefix helper service.
*/
public function __construct(
protected CountryManagerInterface $countryManager,
protected CurrentCountryInterface $currentCountry,
protected PathPrefixHelperInterface $pathPrefixHelper,
) {}
/**
@@ -45,8 +48,10 @@ class CountryEventSubscriber implements EventSubscriberInterface {
}
$path = $event->getRequest()->getPathInfo();
$country_code = PathUtility::getCountryCodeFromPath($path);
if ($this->countryManager->isCountryAllowed($country_code)) {
[, $country_code] = $this->pathPrefixHelper->extractLanguageAndCountry($path);
if ($country_code) {
$this->currentCountry->setCountryCode($country_code);
}
}
Loading