1

My module defines a configuration entity (specifically a BBCode tag macro with a template) that can be created and edited with a web form.

It can also be created by other modules using a config/install/xbbcode.tag.*.yml file - and of course those objects can also be edited and deleted.

Is there a way to access and recreate the original version of a config object that has been edited, without having to reinstall the whole module? I like the flexibility of customizing these templates, but users need to be able to restore the factory settings somehow.

  • 1
    You can use YamlDiscovery to search for that yaml configuration file – Eyal Dec 2 '15 at 0:27
  • 1
    You can create a second configuration entity original.xcode.tag.* that is only created when the xcode.tag entity is created. – Eyal Dec 2 '15 at 0:29
2

Core does not provide such an API, not in a way that is easy to use.

There is a contrib module that provides this, but it's probably too complicated to rely on for a specific use case.

0

After thinking about this for a while, the solution may be to add a special "editable" flag on user-created objects, and block the update/delete operations on everything else with an entity access handler.

A custom "clone" operation could then be used to create an editable copy of the object, leaving the original unchanged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.