diff -u b/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module --- b/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -53,7 +53,7 @@ */ function content_translation_module_implements_alter(&$implementations, $hook) { switch ($hook) { - // Move our entity_type_alter hook implementation to the end of the list. + // Move our hook_entity_type_alter() implementation to the end of the list. case 'entity_type_alter': $group = $implementations['content_translation']; unset($implementations['content_translation']); diff -u b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php --- b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php @@ -218,7 +218,7 @@ if ($entity->hasTranslation($langcode)) { $language = new Language(array('id' => $langcode)); $view_url = $entity->url('canonical', ['language' => $language]); - $elements = $this->xpath('//table//a[@href=:href]', array(':href' => $view_url)); + $elements = $this->xpath('//table//a[@href=:href]', [':href' => $view_url]); $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation.', array('%language' => $langcode))); $edit_path = $entity->url('edit-form', array('language' => $language)); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(':href' => $edit_path)); diff -u b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php --- b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -7,7 +7,6 @@ namespace Drupal\language\Plugin\LanguageNegotiation; - use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; @@ -140,6 +139,7 @@ if (!isset($options['query'][static::QUERY_PARAMETER])) { $query_addon = [static::QUERY_PARAMETER => $langcode]; $options['query'] += $query_addon; + // @todo Remove this once https://www.drupal.org/node/2507005 lands. $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . UrlHelper::buildQuery($query_addon); } @@ -184,6 +184,7 @@ * than the url language negotiator. * * @return bool + * TRUE if the configuration condition is met, FALSE otherwise. */ protected function meetsConfigurationCondition() { if (!isset($this->meetsConfigurationCondition)) { @@ -196,7 +197,7 @@ $check_interface_method = FALSE; if (isset($enabled_methods_content[LanguageNegotiationUI::METHOD_ID])) { $enabled_methods_interface = $this->config->get('language.types')->get('negotiation.language_interface.enabled') ? : []; - $check_interface_method = isset($enabled_methods_interface[LanguageNegotiationUrl::METHOD_ID]) ? TRUE : FALSE; + $check_interface_method = isset($enabled_methods_interface[LanguageNegotiationUrl::METHOD_ID]); } if ($check_interface_method) { $check_against_weight = $enabled_methods_content[LanguageNegotiationUI::METHOD_ID]; @@ -224,14 +225,15 @@ * The HttpRequest object representing the current request. * * @return bool + * TRUE if the content entity route condition is met, FALSE otherwise. */ protected function meetsContentEntityRoutesCondition($outbound_route_name, Request $request) { - $storage = $this->paths->offsetExists($request) ? $this->paths->offsetGet($request) : []; + $storage = isset($this->paths[$request]) ? $this->paths[$request] : []; if (!isset($storage[$outbound_route_name])) { $content_entity_path_for_current_route = $this->getContentEntityPathForCurrentRequest($request); $meets_condition = $content_entity_path_for_current_route ? $this->meetsOutboundRouteToCurrentContentEntityCondition($outbound_route_name, $request) : FALSE; $storage[$outbound_route_name] = $meets_condition; - $this->paths->offsetSet($request, $storage); + $this->paths[$request] = $storage; } return $storage[$outbound_route_name]; @@ -244,6 +246,7 @@ * The HttpRequest object representing the current request. * * @return string + * The path pattern for the content entity from the request. */ protected function getContentEntityPathForCurrentRequest(Request $request) { $content_entity_path_for_current_route = ''; @@ -266,11 +269,13 @@ * The HttpRequest object representing the current request. * * @return bool + * TRUE if the outbound route points to the entity on the current route, + * FALSE otherwise. */ protected function meetsOutboundRouteToCurrentContentEntityCondition($outbound_route_name, Request $request) { if ($content_entity_path_for_current_route = $this->getContentEntityPathForCurrentRequest($request)) { $outbound_route_path = $this->routeProvider->getRouteByName($outbound_route_name)->getPath(); - if (!empty($this->getContentEntityPaths()[$outbound_route_path])) { + if (!empty($this->getContentEntityPaths()[$outbound_route_path]) && $content_entity_path_for_current_route == $this->getContentEntityPaths()[$outbound_route_path]) { return TRUE; } }