- Issue created by @a.dmitriiev
- πΊπΈUnited States phenaproxima Massachusetts
This seems like a reasonable and useful feature, so +1.
I'm not sure that
duplicateIfNotExists
makes sense, though; by definition, you can't duplicate a thing if the duplicate already exists.I would suggest we make this as simple as possible, where the action only takes a string, which is the ID of the duplicate to create. So:
config: actions: core.entity_view_display.node.page.default: # Duplicates the default display, and gives it the ID of node.page.search_result. duplicate: node.page.search_result
In other words, this action should only be able to work on config entities that already exist.
- πΊπΈUnited States phenaproxima Massachusetts
Also, I know this feature will be needed for Drupal CMS, so tagging as a Starshot blocker.
- π¨π¦Canada b_sharpe
Up for discussion, but if I'm wanting to clone an existing config and it doesn't exist, I'd expect an error here rather than just not cloning as this could affect further actions.
- πΊπΈUnited States phenaproxima Massachusetts
I think I agree with you, on second thought. Adjusted!
- π¬π§United Kingdom alexpott πͺπΊπ
Committed and pushed 520019bb2fe to 11.x and 36a124b2f5e to 10.4.x. Thanks!
diff --git a/core/tests/Drupal/KernelTests/Core/Recipe/EntityCloneConfigActionTest.php b/core/tests/Drupal/KernelTests/Core/Recipe/EntityCloneConfigActionTest.php index 5a712a60ab9..dd9472d81f7 100644 --- a/core/tests/Drupal/KernelTests/Core/Recipe/EntityCloneConfigActionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Recipe/EntityCloneConfigActionTest.php @@ -32,6 +32,9 @@ protected function setUp(): void { $this->createRole(['access user profiles'], 'test'); } + /** + * Tests error if original entity does not exist. + */ public function testErrorIfOriginalDoesNotExist(): void { $this->expectException(ConfigActionException::class); $this->expectExceptionMessage("Cannot clone 'user.role.nope' because it does not exist."); @@ -39,6 +42,9 @@ public function testErrorIfOriginalDoesNotExist(): void { ->applyAction('cloneAs', 'user.role.nope', 'user.role.yep'); } + /** + * Tests successful clone. + */ public function testSuccessfulClone(): void { $this->container->get('plugin.manager.config_action') ->applyAction('cloneAs', 'user.role.test', 'cloned'); @@ -48,7 +54,10 @@ public function testSuccessfulClone(): void { $this->assertTrue($clone->hasPermission('access user profiles')); } - public function testNoConflictWithExistingClone(): void { + /** + * Tests no error is thrown when an entity with the same ID already exists. + */ + public function testNoErrorWithExistingEntity(): void { $this->createRole(['administer site configuration'], 'cloned'); $this->container->get('plugin.manager.config_action')
Fixed on commit.
-
alexpott β
committed 36a124b2 on 10.4.x
Issue #3481238 by phenaproxima, a.dmitriiev, b_sharpe, alexpott: Add a...
-
alexpott β
committed 36a124b2 on 10.4.x
-
alexpott β
committed 520019bb on 11.x
Issue #3481238 by phenaproxima, a.dmitriiev, b_sharpe, alexpott: Add a...
-
alexpott β
committed 520019bb on 11.x
-
alexpott β
committed 09e44ad0 on 11.x
Issue #3481238 follow-up by phenaproxima, a.dmitriiev, b_sharpe,...
-
alexpott β
committed 09e44ad0 on 11.x
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Are we not doing change records to announce the availability of this, and in which version it's available? π€
(Very cool BTW!)
- πΊπΈUnited States thejimbirch Cape Cod, Massachusetts
Needs to be added to the docs also.
- πΊπΈUnited States phenaproxima Massachusetts
Change record written: https://www.drupal.org/node/3481718 β
Automatically closed - issue fixed for 2 weeks with no activity.