13.11.2025 | Dominik Wille

Install config from config/install dir in update hook.

redirect.install
/**
 * Save the bulk delete action to config.
 */
function redirect_update_8104() {
  if (!Action::load('redirect_delete_action')) {
    $entity_type_manager = \Drupal::entityTypeManager();
    $module_handler = \Drupal::moduleHandler();

    // Save the bulk delete action to config.
    $config_install_path = $module_handler->getModule('redirect')->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
    $storage = new FileStorage($config_install_path);
    $entity_type_manager
      ->getStorage('action')
      ->create($storage->read('system.action.redirect_delete_action'))
      ->trustData()
      ->save();
  }
}

Issue:

You might maintain a Drupal contrib module and want to add some config at a later stage.

Solution:

The provided snippet implements a hook to create config.

Further information

Similar results can be achieved using the Configuration Replace module.

Weitere DevBits

07.05.2026 | Dominik Wille

Exclude already-displayed entities from a view

Use the views_exclude_previous module. See below or open the module documentation for further information.

14.10.2026 | Lothar Ferreira Neumann

Require a module that is incompatible with your Drupal Core version

lenient.sh
# Get lenient.
composer require mglaman/composer-drupal-lenient

# Add the module to the allow list. Use escapes for the quote signs. \" ... \"
composer config --merge --json extra.drupal-lenient.allowed-list '[\"drupal/module_with_incompatible_core_version\"]'

# You can check if the merge worked, either just take a look
# into the composer.json or use this command.
composer config --merge --json extra.drupal-lenient.allowed-list
lenient_allowed_list.json
"drupal-lenient": {
  "allowed-list": [
    "drupal/module_with_incompatible_core_version"
  ]
}