From 0a5f01c1f0c56ac71cc8ba076b76ec56ee8e0701 Mon Sep 17 00:00:00 2001 From: Matt Glaman Date: Thu, 7 Dec 2023 14:31:48 -0600 Subject: [PATCH 1/7] fix(next): next_entity_type_config dependencies Fixes dependencies in next_entity_type_config for the entity type and bundle being targeted. --- .../next/src/Entity/NextEntityTypeConfig.php | 14 +++++++++++ .../Entity/NextEntityTypeConfigTest.php | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/modules/next/src/Entity/NextEntityTypeConfig.php b/modules/next/src/Entity/NextEntityTypeConfig.php index c6284c170..5144943fe 100644 --- a/modules/next/src/Entity/NextEntityTypeConfig.php +++ b/modules/next/src/Entity/NextEntityTypeConfig.php @@ -240,6 +240,20 @@ public function getPluginCollections() { return $collections; } + /** + * {@inheritdoc} + * + * @todo add sites with onDependencyRemoval support. + */ + public function calculateDependencies() { + parent::calculateDependencies(); + [$entity_type_id, $bundle] = explode('.', $this->id()); + $target_entity_type = $this->entityTypeManager()->getDefinition($entity_type_id); + $bundle_config_dependency = $target_entity_type->getBundleConfigDependency($bundle); + $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); + return $this; + } + /** * Wraps the site_resolver plugin manager. * diff --git a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php index 62680a387..36e539dfc 100644 --- a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php @@ -139,4 +139,27 @@ public function testRevalidator() { $this->assertSame('path', $revalidator->getId()); } + /** + * Tests config dependency calculation. + */ + public function testConfigDependencies(): void { + $blog_site = NextSite::create([ + 'id' => 'blog', + ]); + $blog_site->save(); + + // Create entity type config. + /** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */ + $entity_type_config = NextEntityTypeConfig::create([ + 'id' => 'node.page', + 'site_resolver' => 'site_selector', + 'configuration' => [ + 'sites' => [ + 'blog' => 'blog', + ], + ], + ]); + self::assertEquals([], $entity_type_config->getDependencies()); + } + } From 21ab67b9c1070fb9ac16bae1489f927df34b1f99 Mon Sep 17 00:00:00 2001 From: Matt Glaman Date: Tue, 27 Feb 2024 14:38:58 -0600 Subject: [PATCH 2/7] fix(next): next_entity_type_config dependencies save test entity so dependencies are calculated --- .../next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php index 36e539dfc..62702c2f5 100644 --- a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php @@ -159,6 +159,8 @@ public function testConfigDependencies(): void { ], ], ]); + // Saving causes dependency calculation. + $entity_type_config->save(); self::assertEquals([], $entity_type_config->getDependencies()); } From 317224a860cdd691e066a13e26e3b58aaaec0222 Mon Sep 17 00:00:00 2001 From: Matt Glaman Date: Tue, 27 Feb 2024 14:55:32 -0600 Subject: [PATCH 3/7] fix(next): next_entity_type_config dependencies fix test --- .../tests/src/Kernel/Entity/NextEntityTypeConfigTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php index 62702c2f5..fbf851a2e 100644 --- a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php @@ -5,6 +5,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; /** @@ -42,6 +43,8 @@ protected function setUp(): void { $this->installEntitySchema('path_alias'); $this->installConfig(['filter']); $this->installSchema('node', ['node_access']); + + NodeType::create(['type' => 'page'])->save(); } /** @@ -161,7 +164,11 @@ public function testConfigDependencies(): void { ]); // Saving causes dependency calculation. $entity_type_config->save(); - self::assertEquals([], $entity_type_config->getDependencies()); + self::assertEquals([ + 'config' => [ + 'node.type.page', + ], + ], $entity_type_config->getDependencies()); } } From d7410c4159a37e6aae54a46b8072606cdbf1307d Mon Sep 17 00:00:00 2001 From: Bojan Bogdanovic Date: Thu, 25 Dec 2025 11:11:59 +0100 Subject: [PATCH 4/7] Space fix From dbfd9b3a12134cc41478438eb6b1bba771044d3c Mon Sep 17 00:00:00 2001 From: Bojan Bogdanovic Date: Thu, 25 Dec 2025 11:22:26 +0100 Subject: [PATCH 5/7] Space fix --- .../next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php index 97f023a92..c3df458ac 100644 --- a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php @@ -171,7 +171,7 @@ public function testDraftEnabled() { $entity_type_config->set('draft_enabled', FALSE)->save(); $this->assertFalse($entity_type_config->isDraftEnabled()); } - + /** * Tests config dependency calculation. */ From aa00982f8ad76ed527fdf29baec230103a52017a Mon Sep 17 00:00:00 2001 From: Bojan Bogdanovic Date: Thu, 25 Dec 2025 12:28:09 +0100 Subject: [PATCH 6/7] Add missing page content type --- .../src/Kernel/Controller/NextPreviewUrlControllerTest.php | 3 +++ modules/next/tests/src/Kernel/Entity/NextSiteTest.php | 3 +++ .../next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php | 3 +++ modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php | 3 +++ modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php | 3 +++ .../src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php | 3 +++ 6 files changed, 18 insertions(+) diff --git a/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php b/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php index cd3964cb8..2e3193eb1 100644 --- a/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php +++ b/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php @@ -6,6 +6,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Controller\NextPreviewUrlController; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait; use Symfony\Component\HttpFoundation\Request; @@ -44,6 +45,8 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); + NodeType::create(['type' => 'page'])->save(); + $this->nextSite = NextSite::create([ 'label' => 'Blog', 'id' => 'blog', diff --git a/modules/next/tests/src/Kernel/Entity/NextSiteTest.php b/modules/next/tests/src/Kernel/Entity/NextSiteTest.php index 18e676f3b..fa79be1f0 100644 --- a/modules/next/tests/src/Kernel/Entity/NextSiteTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextSiteTest.php @@ -4,6 +4,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\user\Entity\User; @@ -42,6 +43,8 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); + NodeType::create(['type' => 'page'])->save(); + $this->nextSite = NextSite::create([ 'label' => 'Blog', 'id' => 'blog', diff --git a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php index 6cb1761ab..bd38d008d 100644 --- a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php +++ b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php @@ -5,6 +5,7 @@ use Drupal\dblog\Controller\DbLogController; use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -45,6 +46,8 @@ protected function setUp(): void { $this->installSchema('node', ['node_access']); $this->installSchema('user', ['users_data']); + NodeType::create(['type' => 'page'])->save(); + // Create entity type config. $entity_type_config = NextEntityTypeConfig::create([ 'id' => 'node.page', diff --git a/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php b/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php index 80502d28d..f8d8759e6 100644 --- a/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php +++ b/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php @@ -5,6 +5,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; /** @@ -33,6 +34,8 @@ protected function setUp(): void { $this->installEntitySchema('user'); $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); + + NodeType::create(['type' => 'page'])->save(); } /** diff --git a/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php b/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php index c0f9af99e..5153fed86 100644 --- a/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php +++ b/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php @@ -5,6 +5,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; use GuzzleHttp\ClientInterface; use GuzzleHttp\Psr7\Response as GuzzleResponse; @@ -48,6 +49,8 @@ protected function setUp(): void { $this->installEntitySchema('path_alias'); $this->installConfig(['filter']); $this->installSchema('node', ['node_access']); + + NodeType::create(['type' => 'page'])->save(); } /** diff --git a/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php b/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php index e070141ca..0af01d5bd 100644 --- a/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php +++ b/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php @@ -6,6 +6,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\next\Entity\NextEntityTypeConfig; use Drupal\next\Entity\NextSite; +use Drupal\node\Entity\NodeType; use Drupal\Tests\node\Traits\NodeCreationTrait; use Drupal\Tests\user\Traits\UserCreationTrait; use Drupal\user\Entity\User; @@ -52,6 +53,8 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); + NodeType::create(['type' => 'page'])->save(); + $this->nextSettingsManager = $this->container->get('next.settings.manager'); // Create NextSite entities. From 6e26b59e762a0d65ec777b2b481ffa9203d4a675 Mon Sep 17 00:00:00 2001 From: Bojan Bogdanovic Date: Thu, 25 Dec 2025 13:56:19 +0100 Subject: [PATCH 7/7] Set content type names --- .../src/Kernel/Controller/EntityResourceTest.php | 5 +---- .../Controller/NextPreviewUrlControllerTest.php | 2 +- .../Kernel/Entity/NextEntityTypeConfigTest.php | 2 +- .../next/tests/src/Kernel/Entity/NextSiteTest.php | 2 +- .../Kernel/Event/EntityRevalidatedEventTest.php | 2 +- .../src/Kernel/NextEntityTypeManagerTest.php | 2 +- .../src/Kernel/Plugin/PathRevalidatorTest.php | 2 +- .../Plugin/SimpleOauthPreviewUrlGeneratorTest.php | 2 +- .../tests/src/Kernel/Plugin/SiteResolverTest.php | 15 +++------------ .../Renderer/MainContent/HtmlRendererTest.php | 15 +++------------ 10 files changed, 14 insertions(+), 35 deletions(-) diff --git a/modules/next/modules/next_jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php b/modules/next/modules/next_jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php index 068c0cdbc..a20b591fe 100644 --- a/modules/next/modules/next_jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php +++ b/modules/next/modules/next_jsonapi/tests/src/Kernel/Controller/EntityResourceTest.php @@ -47,10 +47,7 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); - $type = NodeType::create([ - 'type' => 'article', - ]); - $type->save(); + NodeType::create(['type' => 'article', 'name' => 'Article'])->save(); foreach (range(1, 100) as $number) { $article = $this->createNode([ diff --git a/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php b/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php index 2e3193eb1..724243a3b 100644 --- a/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php +++ b/modules/next/tests/src/Kernel/Controller/NextPreviewUrlControllerTest.php @@ -45,7 +45,7 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); $this->nextSite = NextSite::create([ 'label' => 'Blog', diff --git a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php index c3df458ac..ce72fb578 100644 --- a/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php @@ -44,7 +44,7 @@ protected function setUp(): void { $this->installConfig(['filter']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); } /** diff --git a/modules/next/tests/src/Kernel/Entity/NextSiteTest.php b/modules/next/tests/src/Kernel/Entity/NextSiteTest.php index fa79be1f0..3aee8d8aa 100644 --- a/modules/next/tests/src/Kernel/Entity/NextSiteTest.php +++ b/modules/next/tests/src/Kernel/Entity/NextSiteTest.php @@ -43,7 +43,7 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); $this->nextSite = NextSite::create([ 'label' => 'Blog', diff --git a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php index bd38d008d..437f66126 100644 --- a/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php +++ b/modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php @@ -46,7 +46,7 @@ protected function setUp(): void { $this->installSchema('node', ['node_access']); $this->installSchema('user', ['users_data']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); // Create entity type config. $entity_type_config = NextEntityTypeConfig::create([ diff --git a/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php b/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php index f8d8759e6..42461fc96 100644 --- a/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php +++ b/modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php @@ -35,7 +35,7 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); } /** diff --git a/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php b/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php index 5153fed86..9b29ac13b 100644 --- a/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php +++ b/modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php @@ -50,7 +50,7 @@ protected function setUp(): void { $this->installConfig(['filter']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); } /** diff --git a/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php b/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php index 0af01d5bd..89757f3de 100644 --- a/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php +++ b/modules/next/tests/src/Kernel/Plugin/SimpleOauthPreviewUrlGeneratorTest.php @@ -53,7 +53,7 @@ protected function setUp(): void { $this->installConfig(['filter', 'next']); $this->installSchema('node', ['node_access']); - NodeType::create(['type' => 'page'])->save(); + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); $this->nextSettingsManager = $this->container->get('next.settings.manager'); diff --git a/modules/next/tests/src/Kernel/Plugin/SiteResolverTest.php b/modules/next/tests/src/Kernel/Plugin/SiteResolverTest.php index a2671d382..0eeade355 100644 --- a/modules/next/tests/src/Kernel/Plugin/SiteResolverTest.php +++ b/modules/next/tests/src/Kernel/Plugin/SiteResolverTest.php @@ -35,18 +35,9 @@ protected function setUp(): void { $this->installConfig(['filter']); $this->installSchema('node', ['node_access']); - // Create page type. - $page_type = NodeType::create([ - 'type' => 'page', - 'label' => 'Page', - ]); - $page_type->save(); - - $article_type = NodeType::create([ - 'type' => 'article', - 'label' => 'Article', - ]); - $article_type->save(); + // Create content types. + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); + NodeType::create(['type' => 'article', 'name' => 'Article'])->save(); // Create NextSite entities. $blog = NextSite::create([ diff --git a/modules/next/tests/src/Kernel/Renderer/MainContent/HtmlRendererTest.php b/modules/next/tests/src/Kernel/Renderer/MainContent/HtmlRendererTest.php index 11e5ac63a..24c1d36e2 100644 --- a/modules/next/tests/src/Kernel/Renderer/MainContent/HtmlRendererTest.php +++ b/modules/next/tests/src/Kernel/Renderer/MainContent/HtmlRendererTest.php @@ -45,18 +45,9 @@ protected function setUp(): void { $this->installSchema('node', ['node_access']); $this->installSchema('user', ['users_data']); - // Create page type. - $page_type = NodeType::create([ - 'type' => 'page', - 'label' => 'Page', - ]); - $page_type->save(); - - $article_type = NodeType::create([ - 'type' => 'article', - 'label' => 'Article', - ]); - $article_type->save(); + // Create content types. + NodeType::create(['type' => 'page', 'name' => 'Page'])->save(); + NodeType::create(['type' => 'article', 'name' => 'Article'])->save(); // Create NextSite entities. $blog = NextSite::create([