Problem/Motivation

Drupal core recently added the concept of "optional" config. This is config data with dependencies that are optional. If the dependencies are not met, the module is still enabled without the optional config. If the dependent module is later enabled, then the optional config is installed.

Features needs a UI mechanism to mark certain config as "optional" to be stored in /config/optional rather than in /config/install

Proposed resolution

Rather than marking individual config items as optional, it might be better to have a section for "optional dependencies". For example, if we are exporting a View and we put "views" into the optional-dependency group instead of the normal dependency group, then any exported config that depends on views would be saved to /config/optional.

This allows us to handle optional config from the module dependency perspective rather that from the detailed config component perspective.

User interface changes

Add a "optional dependency" component that has the list of checkboxes for each current module dependency (initially unchecked). If the optional dependency is checked, it is unchecked in the normal dependency list. If it is checked in the normal dependency list, it gets unchecked from the optional list.

Comments

nedjo’s picture

I'm thinking initially this should be a new assignment plugin, 'optional'.

  • Give it a low weight to run early.
  • Introduce a new key in the config array, 'directory', defaulting to InstallStorage::CONFIG_INSTALL_DIRECTORY.
  • Provide a configuration form to select configuration types that should be marked optional.
  • In the assignment plugin, iterate through all config in the config array. If the type is one that's designated as optional, set 'directory' to InstallStorage::CONFIG_OPTIONAL_DIRECTORY.

For example: if 'view' is designated as an optional config type, all config of type 'view' will be assigned to InstallStorage::CONFIG_OPTIONAL_DIRECTORY.

This approach will also facilitate integration with Configuration Share, which stores configuration in config/shared; see #2447703: Integrate with Configuration Share and Compatible.

  • nedjo committed 799e550 on 8.x-3.x
    Issue #2532958 by nedjo: in preparation for support of optional...
nedjo’s picture

Status: Active » Needs review
StatusFileSize
new6.9 KB

In #2 I refactored to allow designating of a target subdirectory for given pieces of config.

And here's a patch adding a new assignment plugin that allows selection of types of configuration that should be optional.

Contrary to what I suggested above, it doesn't need a particularly low weight, since it doesn't actually assign any configuration to packages--it just sets the directory that configuration will be exported to, if it's assigned to a package.

TBD: what, if any, types of configuration should be designated optional by default? For now, I haven't set any.

nedjo’s picture

Assigned: Unassigned » nedjo

  • nedjo committed 1d724f9 on 8.x-3.x
    Issue #2532958 by nedjo: Add UI support for optional config.
    
nedjo’s picture

Status: Needs review » Fixed

I went ahead and applied this. If and as we determine what configuration types should be optional by default, we can set them in new issues.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.