Improve API for creating/updating configuration

Created on 24 September 2018, about 6 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

Core uses the ConfigInstaller service to create or update configuration. The ConfigInstaller::createConfiguration() is responsible for "installing" a collection of config and handles the case of existing vs new and simple config vs config entities. However, this function is not Public and contains a bit of installer-specific code.

Other contrib modules, such as Config Actions and Configuration Update Manager (used by Features) have the need to update configuration and have their own methods for this. In the case of Config Actions, code from ConfigInstaller::createConfiguration() was copied/pasted. In Configuration Update Manager the same underlying $entity_storage->createFromStorageRecord and $entity_storage->updateFromStorageRecord methods are used as in ConfigInstaller but missing some details.

Configuration Update Manager needs to preserve the "_core" key data, while core ConfigInstaller needs to determine if the config is being synced and handle the "trustData" and check if the config is Installable. Config Actions also uses trustData (and maybe shouldn't) but doesn't do anything to preserve the "_core" key.

Proposed resolution

Provide a new public method in ConfigInstaller for creating/updating a single config item. This method would be used within ConfigInstaller itself but would also be available for contrib modules that want to install or update configuration.

/**
 * @param \Drupal\Core\Config\StorableConfigBase $config_item
 *   the config item to be updated.
 * @param mixed $data
 *   the data to store into the config item.
 */
public function installConfigItem($config_item, $data)

Remaining tasks

This issue summary is a "work in progress"

User interface changes

API changes

Data model changes

Feature request
Status

Needs work

Version

10.1

Component
Configuration 

Last updated 2 days ago

Created by

🇺🇸United States mpotter

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.71.5 2024