Config action to duplicate config entity

Created on 16 October 2024, about 2 months ago

Problem/Motivation

When new view mode is enabled for the content type, for example, with UI, new view display always is copied from the "Default" display, meaning all the fields that are used in default display are added to the newly enabled display with the same settings. Later the new display can be adjusted to the needs.

Steps to reproduce

When the new view mode is enabled for the content type with recipes, no fields (components) are added to it by default. One needs explicitly provide the components with names and there settings. But sometimes, the names and settings are unknown in advance, and to be flexible and dynamic, it would be nice to have the config action that would copy the default view display, but for another view mode.

I believe there would be a lot of other use cases, for example, creating the config splits for lower environments, as they can be the same with only slight differences, etc.

Proposed resolution

Create config action that will duplicate config entity. For example:

core.entity_view_display.node.page.search_result:
  duplicate:
    name: node.page.default

The config entity that is duplicated of course should be of the same type as the given config. This should be validated in the config action.
It might be interesting to have one more parameter for config action that will have the changes that should be applied to the copy before saving, but this is optional, there are already other actions for this.
As other config actions, this one also needs duplicateIfNotExists option.

Remaining tasks

Create new config action.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

New config action to duplicate config entity. Recipe example usage:

core.entity_view_display.node.page.search_result:
  duplicate:
    name: node.page.default
✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

recipe system

Created by

πŸ‡©πŸ‡ͺGermany a.dmitriiev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024