diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php index 4e2f458..ec9d92e 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -8,18 +8,18 @@ namespace Drupal\language\Plugin\LanguageNegotiation; use Drupal\Component\Utility\UrlHelper; +use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\BubbleableMetadata; +use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Url; use Drupal\language\LanguageNegotiationMethodBase; use Drupal\language\LanguageSwitcherInterface; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; -use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Core\Entity\ContentEntityInterface; /** * Class for identifying the content translation language. @@ -35,7 +35,7 @@ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase implements OutboundPathProcessorInterface, LanguageSwitcherInterface, ContainerFactoryPluginInterface { /** - * The language negotiation method id. + * The language negotiation method ID. */ const METHOD_ID = 'language-content-entity'; @@ -66,7 +66,7 @@ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase imp protected $routeProvider; /** - * The entity manager + * The entity manager. * * @var \Drupal\Core\Entity\EntityManagerInterface */ @@ -190,13 +190,13 @@ protected function meetsConfigurationCondition() { if (!isset($this->meetsConfigurationCondition)) { // 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') ? : []; + $enabled_methods_content = $this->config->get('language.types')->get('negotiation.language_content.enabled') ?: []; // Check if the content language is configured to be dependent on the // url negotiator directly or indirectly over the interface negotiator. $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') ? : []; + $enabled_methods_interface = $this->config->get('language.types')->get('negotiation.language_interface.enabled') ?: []; $check_interface_method = isset($enabled_methods_interface[LanguageNegotiationUrl::METHOD_ID]); } if ($check_interface_method) { @@ -240,13 +240,13 @@ protected function meetsContentEntityRoutesCondition($outbound_route_name, Reque } /** - * Returns the content entity type id from the current request for the route. + * Returns the content entity type ID from the current request for the route. * * @param \Symfony\Component\HttpFoundation\Request $request * The HttpRequest object representing the current request. * * @return string - * The entity type id for the route from the request. + * The entity type ID for the route from the request. */ protected function getContentEntityTypeIdForCurrentRequest(Request $request) { $content_entity_type_id_for_current_route = ''; @@ -285,11 +285,9 @@ protected function meetsOutboundRouteToCurrentContentEntityCondition($outbound_r /** * Returns the paths for the link templates of all content entities. * - * The array will be keyed by the link template paths with the corresponding - * entity type ids as values. - * * @return array - * The array of the link templates paths of all content entities, as keys. + * An array of all content entity type IDs, keyed by the corresponding link + * template paths. */ protected function getContentEntityPaths() { if (!isset($this->contentEntityPaths)) { @@ -305,4 +303,5 @@ protected function getContentEntityPaths() { return $this->contentEntityPaths; } + } diff --git a/core/modules/language/src/Tests/EntityUrlLanguageTest.php b/core/modules/language/src/Tests/EntityUrlLanguageTest.php index e37848c..ce3b461 100644 --- a/core/modules/language/src/Tests/EntityUrlLanguageTest.php +++ b/core/modules/language/src/Tests/EntityUrlLanguageTest.php @@ -87,11 +87,11 @@ public function testEntityUrlLanguageWithLanguageContentEnabled() { // we have to rebuild it. $this->kernel->rebuildContainer(); - // Without being on an content entity route the default entity url tests + // Without being on an content entity route the default entity URL tests // should still pass. $this->testEntityUrlLanguage(); - // Now switching to an entity route, so that the url links are generated + // Now switching to an entity route, so that the URL links are generated // while being on an entity route. $this->setCurrentRequestForRoute('/entity_test/{entity_test}', 'entity.entity_test.canonical'); @@ -115,7 +115,7 @@ public function testEntityUrlLanguageWithLanguageContentEnabled() { // we have to rebuild it. $this->kernel->rebuildContainer(); - // The default entity url tests should pass again with the current + // The default entity URL tests should pass again with the current // configuration. $this->testEntityUrlLanguage(); } diff --git a/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php index 6460272..5373096 100644 --- a/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php +++ b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php @@ -85,7 +85,7 @@ public function testDefaultConfiguration() { } /** - * Test case for enabling the language negotiator language_content_entity. + * Tests enabling the language negotiator language_content_entity. */ public function testEnabledLanguageContentNegotiator() { // Define the method language-url with a higher priority than @@ -120,10 +120,10 @@ public function testEnabledLanguageContentNegotiator() { // The method language-content-entity should run before language-url and // append query parameter for the content language and prevent language-url - // from overwriting the url. + // from overwriting the URL. $default_site_langcode = $this->config('system.site')->get('default_langcode'); - // Now switching to an entity route, so that the url links are generated + // Now switching to an entity route, so that the URL links are generated // while being on an entity route. $this->setCurrentRequestForRoute('/entity_test/{entity_test}', 'entity.entity_test.canonical'); @@ -178,4 +178,5 @@ protected function setCurrentRequestForRoute($path, $route_name) { $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route($path)); $this->container->get('request_stack')->push($request); } + }