Skip to content
Snippets Groups Projects
Commit 2e812d52 authored by James Silver's avatar James Silver Committed by Simon Bäse
Browse files

Issue #3476383 by jamsilver, simonbaese: Compatibility Drupal ^10.3 & Drupal ^11

parent c9586cc0
No related branches found
No related tags found
1 merge request!8Resolve #3476383 "Compatibility Drupal 10.3"
Pipeline #335415 passed
Showing
with 46 additions and 46 deletions
......@@ -9,8 +9,11 @@ include:
- '/includes/include.drupalci.workflows.yml'
variables:
OPT_IN_TEST_MAX_PHP: '1'
OPT_IN_TEST_NEXT_MINOR: '1'
OPT_IN_TEST_CURRENT: 1
OPT_IN_TEST_MAX_PHP: 1
OPT_IN_TEST_PREVIOUS_MAJOR: 1
_CSPELL_WORDS: 'Bäse, Demianik'
_PHPUNIT_EXTRA: "--testdox"
phpcs:
allow_failure: false
......
......@@ -41,7 +41,7 @@ This module provides a lightweight implementation of a language negotiation plug
Please note that this module is still in development, and several planned enhancements are in the pipeline before reaching a stable release. These include:
1. ~~Custom Entity for Countries: Implement a custom entity structure for representing countries.~~ (Done)
2. Country Switcher Block: Improve the country switcher block and its corresponding template.
2. ~~Country Switcher Block: Improve the country switcher block and its corresponding template.~~ (Done)
3. Plugin Configuration: Allow configuration options for the prefix pattern, exclusion of admin pages from negotiation, and enabling strict negotiation (disallowing the international state).
4. Sub-Modules: Create submodules to manage different fallback mechanisms.
5. Integration: Connect with the Entity Language Fallback module.
......
......@@ -19,6 +19,6 @@
"issues": "https://www.drupal.org/project/issues/language_country_negotiation"
},
"require": {
"drupal/core": "^10"
"drupal/core": "^10.3 || ^11"
}
}
......@@ -2,7 +2,7 @@ name: Language-Country Negotiation
type: module
description: Provides an additional country-dependent language negotiation plugin.
package: Multilingual
core_version_requirement: ^10
core_version_requirement: ^10.3 || ^11
configure: language.negotiation
dependencies:
- drupal:locale
......
parameters:
level: 7
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- identifier: missingType.generics
- identifier: missingType.iterableValue
# new static() is a best practice in Drupal.
- "#^Unsafe usage of new static#"
drupal:
......
......@@ -18,7 +18,7 @@ class CountryCacheContext implements CacheContextInterface {
* The current country service.
*/
public function __construct(
protected CurrentCountryInterface $currentCountry
protected CurrentCountryInterface $currentCountry,
) {}
/**
......
......@@ -143,7 +143,7 @@ class Country extends ContentEntityBase implements EntityChangedInterface, Entit
->setDescription(new TranslatableMarkup('The two-letter code of the country, for example <em>de</em> for Germany.'))
->setRequired(TRUE)
->setTranslatable(FALSE)
->addConstraint('CountryCode')
->addConstraint('LcnCountryCode')
->addConstraint('UniqueField')
->setDisplayOptions('form', [
'type' => 'string_textfield',
......
......@@ -32,7 +32,7 @@ class CountryEventSubscriber implements EventSubscriberInterface {
*/
public function __construct(
protected CountryManagerInterface $countryManager,
protected CurrentCountryInterface $currentCountry
protected CurrentCountryInterface $currentCountry,
) {}
/**
......
......@@ -38,7 +38,7 @@ class RequestFallbackEventSubscriber implements EventSubscriberInterface {
public function __construct(
protected ConfigFactoryInterface $configFactory,
protected CountryManagerInterface $countryManager,
protected KillSwitch $killSwitch
protected KillSwitch $killSwitch,
) {}
/**
......
......@@ -16,11 +16,10 @@ class LanguageCountryNegotiationServiceProvider extends ServiceProviderBase {
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container): void {
if ($container->hasDefinition('path_alias.manager')) {
$definition = $container->getDefinition('path_alias.manager');
$definition->setClass(FallbackAliasManager::class);
$definition->addArgument(new Reference('config.factory'));
$definition->addMethodCall('setConfigFactory', [new Reference('config.factory')]);
}
}
......
......@@ -64,7 +64,7 @@ class LanguageNegotiationLanguageCountryUrl extends LanguageNegotiationUrl imple
/**
* {@inheritdoc}
*/
public function getLangcode(Request $request = NULL): ?string {
public function getLangcode(?Request $request = NULL): ?string {
$negotiated_langcode = NULL;
......@@ -118,7 +118,7 @@ class LanguageNegotiationLanguageCountryUrl extends LanguageNegotiationUrl imple
/**
* {@inheritdoc}
*/
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL): string {
public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL): string {
// Admin paths shall use the standard language path prefix without country
// information.
......
......@@ -8,7 +8,7 @@ use Symfony\Component\Validator\Constraint;
* Checks if a country code field provides a two-letter value.
*
* @Constraint(
* id = "CountryCode",
* id = "LcnCountryCode",
* label = @Translation("Country code constraint", context = "Validation"),
* )
*/
......
......@@ -17,7 +17,7 @@ class CountryManager implements CountryManagerInterface {
*/
public function __construct(
protected CountryRepositoryInterface $countryRepository,
protected CurrentCountryInterface $currentCountry
protected CurrentCountryInterface $currentCountry,
) {}
/**
......
......@@ -35,7 +35,7 @@ class CountryRepository implements CountryRepositoryInterface {
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager,
protected LanguageManagerInterface $languageManager,
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {}
/**
......
......@@ -2,13 +2,9 @@
namespace Drupal\language_country_negotiation\Service;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\path_alias\AliasManager;
use Drupal\path_alias\AliasRepositoryInterface;
use Drupal\path_alias\AliasWhitelistInterface;
/**
* Extends the alias manager to consider fallback languages.
......@@ -16,27 +12,23 @@ use Drupal\path_alias\AliasWhitelistInterface;
class FallbackAliasManager extends AliasManager {
/**
* Constructs a new FallbackAliasManager service object.
* The config factory.
*
* @param \Drupal\path_alias\AliasRepositoryInterface $alias_repository
* The path alias repository.
* @param \Drupal\path_alias\AliasWhitelistInterface $whitelist
* The whitelist implementation to use.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* Cache backend.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected ConfigFactoryInterface $configFactory;
/**
* Sets the config factory for this service.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*
* @return $this
*/
public function __construct(
AliasRepositoryInterface $alias_repository,
AliasWhitelistInterface $whitelist,
LanguageManagerInterface $language_manager,
CacheBackendInterface $cache,
protected ConfigFactoryInterface $configFactory
) {
parent::__construct($alias_repository, $whitelist, $language_manager, $cache);
public function setConfigFactory(ConfigFactoryInterface $config_factory): self {
$this->configFactory = $config_factory;
return $this;
}
/**
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\language_country_negotiation\Functional;
use Drupal\Tests\system\Functional\Module\GenericModuleTestBase;
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\language_country_negotiation\Kernel;
use Drupal\language_country_negotiation\Service\CountryManagerInterface;
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\language_country_negotiation\Kernel;
use Drupal\language_country_negotiation\Service\CountryRepositoryInterface;
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\language_country_negotiation\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
......
......@@ -8,14 +8,14 @@ use Drupal\Core\Render\AttachmentsInterface;
use Drupal\Core\Routing\LocalRedirectResponse;
use Drupal\Core\Routing\StackedRouteMatchInterface;
use Drupal\Core\Url;
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
use Drupal\Tests\language_country_negotiation\Traits\RequestTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback;
use Drupal\language_country_negotiation\Plugin\LanguageNegotiation\LanguageNegotiationLanguageCountryUrl;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\language_country_negotiation\Traits\RequestTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -170,9 +170,7 @@ class NegotiationRedirectTest extends CountryTestBase {
$this->installEntitySchema('node');
$this->installEntitySchema('path_alias');
// @todo Deprecated in Drupal 10.1 and changed in Drupal 11.
// @phpstan-ignore-next-line
$account = $this->createUser([], [
$account = $this->createUser([
'access content',
'access administration pages',
]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment