diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php index 1010e33..980759d 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -54,9 +54,11 @@ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase imp /** * Static cache for the language negotiation order check. * + * @see \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::hasHigherLanguageNegotiationOrder() + * * @var bool */ - protected $languageNegotiationOrderCheckResult; + protected $hasHigherLanguageNegotiationOrderResult; /** * The route provider. @@ -115,7 +117,7 @@ public function getLangcode(Request $request = NULL) { */ public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { // Check if processing conditions are met. - if (!($request && !empty($options['route_name']) && $this->checkLanguageNegotiationOrder() && $this->meetsContentEntityRoutesCondition($options['route_name'], $request))) { + if (!($request && !empty($options['route_name']) && $this->hasHigherLanguageNegotiationOrder() && $this->meetsContentEntityRoutesCondition($options['route_name'], $request))) { return $path; } @@ -178,16 +180,20 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { } /** - * Determines the execution permission based on the current configuration. + * Determines if content entity language negotiator has higher priority. * - * Requirement: the content entity language negotiator has higher priority - * than the url language negotiator. + * The content entity language negotiator having higher priority than the url + * language negotiator, is a criteria for deciding if + * \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::processOutbound() + * should be executed to remove the language option, so that url negotiator + * does not rewrite the url. * * @return bool - * TRUE if the configuration condition is met, FALSE otherwise. + * TRUE if the the content entity language negotiator has higher priority + * than the url language negotiator, FALSE otherwise. */ - protected function checkLanguageNegotiationOrder() { - if (!isset($this->languageNegotiationOrderCheckResult)) { + protected function hasHigherLanguageNegotiationOrder() { + if (!isset($this->hasHigherLanguageNegotiationOrderResult)) { // Only run if the LanguageNegotiationContentEntity outbound function is // being executed before the outbound function of LanguageNegotiationUrl. $enabled_methods_content = $this->config->get('language.types')->get('negotiation.language_content.enabled') ?: []; @@ -195,7 +201,7 @@ protected function checkLanguageNegotiationOrder() { // Check if the content language is configured to be dependent on the // url negotiator directly or indirectly over the interface negotiator. if (isset($enabled_methods_content[LanguageNegotiationUrl::METHOD_ID]) && ($enabled_methods_content[static::METHOD_ID] > $enabled_methods_content[LanguageNegotiationUrl::METHOD_ID])) { - $this->languageNegotiationOrderCheckResult = FALSE; + $this->hasHigherLanguageNegotiationOrderResult = FALSE; } else { $check_interface_method = FALSE; @@ -211,11 +217,11 @@ protected function checkLanguageNegotiationOrder() { $check_against_weight = isset($enabled_methods_content[LanguageNegotiationUrl::METHOD_ID]) ? $enabled_methods_content[LanguageNegotiationUrl::METHOD_ID] : PHP_INT_MAX; } - $this->languageNegotiationOrderCheckResult = $enabled_methods_content[static::METHOD_ID] < $check_against_weight; + $this->hasHigherLanguageNegotiationOrderResult = $enabled_methods_content[static::METHOD_ID] < $check_against_weight; } } - return $this->languageNegotiationOrderCheckResult; + return $this->hasHigherLanguageNegotiationOrderResult; } /**