Workflow
A workflow in Drupal is a configuration entity of the core Workflows module: a named set of states and the transitions allowed between them.
A Drupal workflow describes a process as stages and the moves allowed between them, for example from Draft to Published. It is stored as configuration. On its own it only describes a process; a workflow type, such as the one from Content Moderation, connects it to something real, such as publishing a page.
How workflows work in Drupal 11
The Workflows module provides an admin interface and an API. The module description says the states come from other modules, for example publication status. The workflow itself is the config entity Drupal\workflows\Entity\Workflow. It exports four keys: id, label, type and type_settings. The collection page is /admin/config/workflow/workflows and it needs the Administer workflows permission.
The type value names a workflow type plugin. The type plugin owns the behavior: it keeps the states and transitions (methods such as addState(), addTransition() and getTransitionsForState() live on WorkflowTypeInterface) and lists the states it requires. The Content Moderation type, with ID content_moderation, requires a draft and a published state.
A transition has a label, one or more states it starts from, and one state it leads to. Modules that use a workflow, like Content Moderation, build their permissions on transitions, so a role can be allowed one move but not another.
Example
This shortened excerpt is from the Editorial workflow that Drupal core ships in the Standard profile. The file is named workflows.workflow.editorial.yml.
id: editorial
label: Editorial
type: content_moderation
type_settings:
states:
draft:
label: Draft
published: false
default_revision: false
published:
label: Published
published: true
default_revision: true
transitions:
publish:
label: Publish
from:
- draft
- published
to: published
default_moderation_state: draft
The full file also defines an Archived state and four more transitions.
Common mistakes
- Enabling Workflows and expecting moderated content. Without a type that is applied to content types, a workflow changes nothing on your pages.
- Deleting a state that is in use. Drupal refuses while content uses it. It also refuses to delete the last state or one the workflow type requires.
- Rebuilding the workflow by hand on each environment. It is configuration, so export it and import it where you need it.
- Forgetting the transition permissions. With Content Moderation, a role can only use the transitions it has been granted.
For marketing and content teams
The workflow is the written process of your team in a form Drupal can enforce. Decide the stages (for example write, review, publish) and which role makes each move, then ask your site builder to set up Content Moderation to match. The individual stages are explained under workflow states.
Sources
- Drupal.org: Workflows module
- Workflows module definition, Drupal core source (11.4.x)
- Workflow entity, Drupal core source (11.4.x)
- Workflow class, Drupal API
- WorkflowTypeInterface, Drupal API
- WorkflowAddForm, Drupal core source (11.4.x)
- Editorial workflow of the Standard profile, Drupal core source (11.4.x)
- Drupal.org: Content Moderation overview