Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX][D8] Allow config files to have dependencies #4188

Open
Tracked in #5240
jenlampton opened this issue Nov 1, 2019 · 4 comments
Open
Tracked in #5240

[DX][D8] Allow config files to have dependencies #4188

jenlampton opened this issue Nov 1, 2019 · 4 comments

Comments

@jenlampton
Copy link
Member

@jenlampton jenlampton commented Nov 1, 2019

October 2021 update:

In early Drupal 8.x (back in 2014), they've implemented config dependencies with https://www.drupal.org/project/drupal/issues/2080823. Here's an excerpt from the respective change record:

Description:

Configuration entities can depend on modules, themes and other configuration entities. The dependency system is used during configuration installation to ensure that configuration entities are imported in the correct order. For example, node types are created before their fields and the fields are created before their field instances.

Dependencies are stored to the configuration entity's configuration object so that they can be checked without the module that provides the configuration entity class being installed. This is important for configuration synchronization which needs to be able to validate configuration in the sync directory before the synchronization has occurred.

At a later point, in 2015, they've implemented "enforcing" of dependencies with https://www.drupal.org/project/drupal/issues/2224581. Change record here. So a config file in Drupal may look like so:

dependencies:
  config:
    - field.storage.media.field_media_image
    - media.type.image
  enforced:
    module:
      - media
  module:
    - image
  theme:
    - bartik

Original issue summary

From @quicksketch in #1811

I love the idea of importing a whole site into a fresh environment, and having it automatically download and install the needed modules. That would be slick! But first, let's fix this part so that config files know which modules they need.

This also makes me wonder if the config files should have a list of dependencies, rather than a single module. e.g. a _config_dependencies entry rather than just _config_module. Then module extending config files (e.g. the node.type.* config files) could do something like:

$config = config('node.type.foo');
$config->set('my_module_setting', 'foo');
$config->addDependency('my_module');
$config->save();

Then importing the content type config file would know it needs not just the node module but also the extending module(s). Right now we don't actually track this at all, so we have no idea that a module that extends an existing config file would also be needed.

@docwilmot
Copy link
Contributor

@docwilmot docwilmot commented Nov 2, 2019

I'm trying to understand when this would be required. I imagine we mean when a module saves data to a config file (if that module does not own the hook_config_info() for that config file) it should add itself as a dependency?

@jenlampton
Copy link
Member Author

@jenlampton jenlampton commented Nov 2, 2019

Yeah, something like that. Maybe path would add's itself to a dependency on node, as soon as a node type gets a default path pattern?

@stpaultim
Copy link
Member

@stpaultim stpaultim commented Nov 2, 2019

I don't yet know if this is a good idea, but the use case that occurs to me for config files declaring dependencies would be if we allow batching config file into recipes, ala: #3763

I created an experimental project, which is basically a library of config recipes to add features to a site. https://github.com/backdrop-contrib/config_recipes

These recipes include the config for a content types, custom fields and field instances, as well as views. An example recipe that is included is locations. The locations recipes requires that the address field module and the geo suite of modules are installed. For now, I just included a note in the readme for that recipe.

This use case assume that the Backdrop equivalent for the features module involves packages of config files. Other might have better ideas for accomplishing this goal.

@stpaultim
Copy link
Member

@stpaultim stpaultim commented Nov 3, 2019

I uploaded a 13 min video demo of a config recipe use case for this: https://youtu.be/VgFibVrEZEw

@klonos klonos changed the title Allow config files to have dependencies [DX][D8] Allow config files to have dependencies Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants