diff --git a/metatag.module b/metatag.module index fec5014..0200e70 100644 --- a/metatag.module +++ b/metatag.module @@ -421,15 +421,13 @@ function metatag_get_route_entity() { // one bundle and it's named the same as the entity type, so some shortcuts // can be used. if ($route_name == 'user.admin_create') { - $entity_type = $type = 'user'; + $entity_type = 'user'; $definition = Drupal::entityTypeManager()->getDefinition($entity_type); - if (!empty($type)) { - return \Drupal::entityTypeManager() - ->getStorage($entity_type) - ->create([ - $definition->get('entity_keys')['bundle'] => $type, - ]); - } + return \Drupal::entityTypeManager() + ->getStorage($entity_type) + ->create([ + $definition->get('entity_keys')['bundle'] => $entity_type, + ]); } // Trigger hook_metatag_route_entity(). diff --git a/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php b/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php index e76727d..09a9150 100644 --- a/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php +++ b/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php @@ -93,6 +93,8 @@ public function output() { return $element; } + + return ''; } /** diff --git a/src/Form/MetatagDefaultsForm.php b/src/Form/MetatagDefaultsForm.php index a91e171..aedb949 100644 --- a/src/Form/MetatagDefaultsForm.php +++ b/src/Form/MetatagDefaultsForm.php @@ -109,7 +109,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['#suffix'] = ''; $default_type = NULL; - if (!empty($metatag_defaults)) { + if ($metatag_defaults) { $default_type = $metatag_defaults->getOriginalId(); } else { diff --git a/src/MetatagDefaultsListBuilder.php b/src/MetatagDefaultsListBuilder.php index ed86df8..af766b3 100644 --- a/src/MetatagDefaultsListBuilder.php +++ b/src/MetatagDefaultsListBuilder.php @@ -28,7 +28,11 @@ protected function getEntityIds() { $entity_ids = $query->execute(); // Load global entity always. - return $entity_ids + $this->getParentIds($entity_ids); + $parents = $this->getParentIds($entity_ids); + if (!empty($parents)) { + $entity_ids + $parents; + } + return $entity_ids; } /** diff --git a/tests/src/Functional/DefaultTags.php b/tests/src/Functional/DefaultTags.php index 61c7321..279fbac 100644 --- a/tests/src/Functional/DefaultTags.php +++ b/tests/src/Functional/DefaultTags.php @@ -62,6 +62,7 @@ protected function setUp(): void { public function testFrontpage() { $this->drupalGet(''); $this->assertSession()->statusCodeEquals(200); + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); $this_page_url = $this->buildUrl(''); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); @@ -76,6 +77,7 @@ public function testCustomRoute() { $this->assertSession()->pageTextContains('Hello world!'); // Check the meta tags. + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); $this_page_url = $this->buildUrl('/metatag_test_custom_route'); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); @@ -93,6 +95,7 @@ public function testNode() { $this->assertSession()->statusCodeEquals(200); // Check the meta tags. + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); } @@ -108,6 +111,7 @@ public function testTerm() { $this->assertSession()->statusCodeEquals(200); // Check the meta tags. + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); } @@ -116,15 +120,16 @@ public function testTerm() { * Test the default values for a User entity. */ public function testUser() { - // $account = User::load($this->rootUser->id()); - $account = User::load(1); + // Log in as user 1. + $account = $this->loginUser1(); $this_page_url = $account->toUrl('canonical', ['absolute' => TRUE])->toString(); - // Load the user's entity page. + // Load the user/1 entity page. $this->drupalGet($this_page_url); $this->assertSession()->statusCodeEquals(200); // Check the meta tags. + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); $this->drupalLogout(); @@ -153,6 +158,7 @@ public function testUserLoginPages() { $this->assertSession()->statusCodeEquals(200); // Check the meta tags. + // @todo Expand this selection to cover additional meta tags. $xpath = $this->xpath("//link[@rel='canonical']"); $this->assertNotEquals((string) $xpath[0]->getAttribute('href'), $front_url); self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url); diff --git a/tests/src/Functional/MetatagHelperTrait.php b/tests/src/Functional/MetatagHelperTrait.php index 3da21f4..32a55c8 100644 --- a/tests/src/Functional/MetatagHelperTrait.php +++ b/tests/src/Functional/MetatagHelperTrait.php @@ -15,6 +15,9 @@ trait MetatagHelperTrait { /** * Log in as user 1. + * + * @return \Drupal\user\Entity\User + * The full user object for user 1, after logging in. */ protected function loginUser1() { // Load user 1. @@ -31,6 +34,8 @@ protected function loginUser1() { // Login. $this->drupalLogin($account); + + return $account; } /**