Configuration Entities

In this series, you will learn about Configuration Entities and, as a module developer, how to utilize Drupal's Configuration API to store, retrieve, and utilize configuration data in settings or configuration forms.

In this series of tutorials, you'll learn how to make use of various aspects of configuration entities, including:

  • Default configuration
  • Simple configuration
  • Configuration entities
  • Administrative settings forms
  • Configuration entity data in a form

To learn how to manage configuration and workflows in Drupal, see the tutorial series, Configuration Management. To learn how to use other types of entities, see our tutorial series, Drupal Entity API.

Tutorials in this course
Drupal 8, 9, and 10
More information

Configuration entities are suitable for creating user-defined configuration, such as image styles, views, content types, etc. A configuration entity type is defined by a module, default configuration is provided by that module as well as any other module, and then users can create zero or more configuration entities through Drupal's administrative UI.

In this tutorial, you will learn about:

  • What configuration entities are
  • Configuration entity types versus configuration entities
  • An example in core: image style
  • Overview of the process of creating your own configuration entity types in a module
Drupal 8, 9, and 10
More information

In this tutorial, you'll learn about the two types of configuration data: simple configuration and configuration entities. By the end of this tutorial, you should have a better understanding of which type of configuration to use in your module.

More information

When you create a module for Drupal, it can be useful to provide default configuration. This can be settings for a form, the placement of a block, or something more complex like the default image styles provided by the Image module in core. A module can provide default configuration for simple configuration or configuration entities.

In this tutorial, we will cover:

  • Possible locations for default configuration
  • What happens with configuration when a module is installed or uninstalled
  • Managing dependencies in configuration
  • Where to find examples of default configuration
More information

As we learned in Configuration Data Types, simple configuration is suitable for storing module settings as boolean values, integers, or text strings in one or more key/value pairs. In this tutorial, we'll walk through creating a schema and providing default configuration to store initial settings that a module needs to function.

More information

As a developer, within a module, you can define settings for the module and provide a configuration form for administrators to update the values of those settings. In this tutorial, we'll create a configuration settings form for a module and define default values for each setting. We'll use Drupal Console, a command-line utility for Drupal to do some code scaffolding and speed up the process.

By the end of this lesson, you should be able to get a basic settings form up and running inside a custom module complete with default settings and a menu link.

More information

Now that we have some default simple configuration stored in a settings YAML file, let's utilize it in a form that our site administrators can use to update those values. We'll make use of some services and methods in Drupal's Configuration API in order to retrieve, update, and save simple configuration values with a form.

Drupal 8, 9, and 10
More information

In this tutorial we’re going to walk through the process of creating a custom configuration entity in Drupal in a custom module. We'll be using Drupal Console's generate:entity:config command to create and update the files in our Transcode Profile example module. After Drupal Console has generated and updated the files for our configuration entity, we'll walk through each file and see how they define data structure, metadata, an administrative interface, and menu links for a configuration entity in Drupal.

By the end of this tutorial, you should be able to:

  • Use Drupal Console to generate a configuration entity
  • Identify files associated with a configuration entity and summarize the purpose and function of the code inside each file
  • Find other examples of configuration entities in Drupal core
More information

In this tutorial, you'll learn how to add a property to a configuration entity in Drupal. Previously, we created a configuration entity called Transcode Profile and learned about the files and code that compose a configuration entity. Now, we'll add a new property called codec to this configuration entity and learn some new concepts in the process.

In order to add this new property to our custom configuration entity, we'll need to update our schema file, configuration entity forms, the entity list builder class, and add getter and setter methods to our main TranscodeProfile class.

More information

In this tutorial, we'll cover how to load configuration entity data in a module. We'll change the AdminSettingsForm.php we created and replace the simple textfield we were using with a dropdown select list. Then we'll use data from our Transcode Profile module's configuration entity, loaded by the EntityTypeManager via the services container, to choose our preferred Transcode Profile.

By the end of this tutorial, you should be able to:

  • Know how to load configuration entities using EntityTypeManager via the services container
  • Update the AdminSettingsForm.php to use a dropdown select list
  • Save your preferred transcode profile from a list of transcode profile entities
  • Update the default configuration provided with the demo module to include transcode profiles
This course appears in the following guides:
Module Development
Explore Drupal APIs and development patterns in depth.

Develop Drupal Sites