Module Development

Define a New Config Action for Drupal 10, 11

The built-in config actions in Drupal core cover most common scenarios. But sometimes you need custom operations specific to your feature or the configuration your module relies on. You can create custom config actions by defining them as plugins or by adding PHP attributes to a configuration entity class's methods. Let's implement a custom config action to toggle an SEO strict mode setting to learn how to extend recipes with domain-specific configuration operations and make them reusable across your projects.

In this tutorial, we will:

  • Identify scenarios where custom config actions are warranted.
  • Understand the two implementation patterns: plugins and attributed methods.
  • Implement a custom config action in a module.

By the end of this tutorial, you'll be able to implement custom config actions that extend the configuration API provided to your recipes, making platform-specific operations reusable and declarative.