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
Using Drush to work with the Drupal Configuration System is straightforward when working locally. Navigate to the directory containing your site, then issue whatever Drush command you need.
Things become more complicated when multiple environments become involved. Often, a configuration change will need to be made on the production ("live") site and then need to be persisted to a Git repository later. When this occurs, Drush once more provides a solution in the form of the config-pull
subcommand.
Note: Drush 8 and the latest version use different methods and file types for configuration files. This tutorial will demonstrate methods that are compatible with the latest version of Drush with notes related to Drush 8.
There are some administrative UI tools for managing configuration, but some tasks can only be completed with Drush. As a site administrator, you will find Drush an indispensable tool for managing configuration between instances of the same site. Furthermore, Drush includes integration with Git in certain commands, enabling you to create a configuration workflow with Drush that also uses best practices in version control.
By the end of this lesson you should be able to:
- Get the status of a site's configuration
- List configuration on a site
- View configuration objects
- Set values for a specific key inside a configuration object
- Edit a configuration object in active configuration without needing a configuration form
- Integrate a Git workflow with Drush
When working on configuration in a module, whether as part of a migration that uses Migrate Plus configuration entities, or while developing custom configuration entities, you'll often need to re-import the configuration stored in the .yml files of the modules config/install/ or config/optional/ directories. This is tricky though, because Drupal only reads in those default configuration settings when the module is first enabled. So any changes you make to those files after the module has been installed will not be reflected without these workarounds.
Knowing how to do this can improve the developer experience of adding (or debugging) the default configuration that's provided with a module. Or for anyone using Migrate Plus configuration entities as part of a migration.
In this tutorial we'll:
- Learn about the Configuration Development module
- Look at how you can use Drush to perform a partial configuration import
- Write an implementation of
hook_uninstall()
to remove a module's configuration when it's uninstalled
By the end of this tutorial you should be able to re-import the configuration provided by a module without having to uninstall and then reinstall the module.
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.
The Configuration Manager module gives you as an administrator the ability to import and export configuration items on different instances of a Drupal site using a graphical user interface. In this tutorial, we'll take a tour of the Configuration Manager and the administrative interface it provides.
By the end of this lesson you will be able to:
- Access administrative pages for Import, Export, and Synchronize
- Find and configure permissions for Configuration Manager
- Identify the 3 primary actions of configuration management and how to perform them using the UI
While the administrative UI for Configuration synchronization certainly provides a simple and effective means to export and import configuration, it is by no means the preferred method. The Drush command line utility provides the same functionality without the need for a web interface or the need to log in.
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
The real power of the Workflows module is the fact that you can define your own custom workflows. Creating a new custom workflow requires adding a new workflow, and configuring the states and transitions that workflow will use.
In this tutorial we'll:
- Create and configure a new workflow
- Define and configure a set of states and transitions for the workflow
- Understand some best practices to keep in mind when defining workflows
By the end of this tutorial you'll be able to define your own custom workflows for any use-case.
The Content Moderation module exposes data about a content item's moderation state to Views. That allows us to use that information when building custom views. The data includes a moderation state field, filter, and a relationship to the moderation state entity.
In this tutorial we'll:
- Build a new view that uses the moderation state field and lists all revisions for a content item
- Display that view as a block which can be shown on any content page
By the end of this tutorial you'll know how to use the moderation state field in a view.
The Content Moderation module allows you to apply an editorial workflow to your content. Doing so changes some of the ways that content managers will mark an item as published, archive an item, or create new revisions.
In this tutorial we'll:
- Look at the changes to the content editing form that happen when you apply an editorial workflow
- Learn how to edit a piece of content to change its state, and transition it through the editorial workflow
By the end of this tutorial you'll know how to create, and manage, content in an editorial workflow.
Many sites are built around their content, especially Drupal sites. To manage this content, a strict editorial workflow is often highly desirable to make sure the content is drafted, reviewed, published, updated, and archived when ready.
In this tutorial we'll:
- Discuss the various components you'll need to define before you can start building a custom editorial workflow
- Provide an example editorial workflow plan
By the end of this tutorial you will better understand the use case for content moderation, and be able to create an editorial workflow plan for your use-case.
In order to enforce that an editorial workflow is applied to a specific content type you need to update the workflow's configuration. Then, depending on your needs, you may also need to configure new user roles, giving them permission to transition a content item from one state to another.
This process works for any Content Moderation type workflow -- including the Editorial workflow that Drupal provides and any custom workflows you've created.
In this tutorial we'll:
- Update a workflow so that its rules are applied to a content type
- Review the list of permissions provided by a workflow and see how we can set things up to restrict certain users to only perform specific transitions
By the end of this tutorial you will be able to configure a workflow so that it applies to one or more content types, and configure permissions so only users in a specific role can transition content items from one state to another.
When building views of moderated content there are some important things to be aware of. One is the difference between choosing Content or Content revisions as the base for your view. You should also know about some fields and filters added by the Content Moderation module.
In this tutorial we'll:
- Understand when, and why, to choose Content revisions as the base for your view instead of Content
- Learn about the fields, and filters, added by the Content Moderation module
- Learn how to update the view at admin/content/moderate that comes with the Content Moderation module to make it work with any workflow.
By the end of this tutorial you should understand the important concepts necessary to create views of moderated content.
What Are Revisions?
FreeDrupal has had revisions for a long, long time. However, they have often been under-utilized. Understanding how revisions work and how the Content Moderation module works with them is important to for being able to take full advantage of the systems features.
In this tutorial we'll:
- Explain what the different types of revisions are
- Understand when, and how, revisions are created
By the end of this tutorial you should have an understanding of what each type of revision is, how they're created, and how to work with them.
The Workflows and Content Moderation modules allow an editorial team to put any type of content administered in Drupal through a customized editorial workflow and moderation process. Workflow states, such as draft, ready for review, or approved are defined using the Workflows module. The ability to attach moderation states to entity bundles -- a common example being content types -- is configurable by the Content Moderation module.
Both modules have stable releases and are perfectly safe to use in production.
In this tutorial we'll:
- Learn about the use case for Workflows and Content Moderation modules
- Define the role that each module performs
- Define some common terms you'll need to understand when working with these two modules
By the end of this tutorial you will have a good understanding of what the Workflows and Content Moderation modules are, what different functionality they provide, and the permissions made available by the modules.
Drupal Coding Standards
TopicCoding standards provide a set of rules for how your code should be formatted, and best practice guidelines for naming conventions and the location of files.
Comments
TopicComments are a content entity type that allows users to leave commentary associated with a specific piece of content.
Content Modeling
TopicContent modeling consists of identifying and constructing the different building blocks of data that compose the information on your site.
Content Types
TopicA content type is a subtype of the [content entity](link to Entity topic). When a content creator goes to add new content to the site, they are presented with a list of content types to choose from to get the appropriate form to fill out.