Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Facets 3.0.6 Minor update available for module facets (3.0.6). Release: Facets 3.0.5 Minor update available for module facets (3.0.5). Release: Flag 5.1.0 Minor update available for module flag (5.1.0). Release: Block Layout Accordion 1.0.2 Minor update available for module block_layout_accordion (1.0.2). Release: Canvas interactive toggle 1.0.2 Minor update available for module canvas_interactive_toggle (1.0.2). Release: Views HTTP Client 1.0.2 Minor update available for module views_http_client (1.0.2). Release: Block Layout Accordion 1.0.1 Minor update available for module block_layout_accordion (1.0.1). Release: Canvas interactive toggle 1.0.1 Minor update available for module canvas_interactive_toggle (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

State Machine

28,785 sites Security covered Drupal 9–11
View on drupal.org

This module provides code to manage entity lifecycles through defined states and transitions. It uses a special field type to track the current state and allows developers to easily define and apply workflows.

State Machine

Provides code-driven workflow functionality.

A workflow is a set of states and transitions that an entity goes through during its lifecycle. A transition represents a one-way link between two states and has its own label.

Drupal 8

Workflows and workflow groups are plugins defined in YAML, similar to menu links.

The current state is stored in a special field type (StateItem), which references the used workflow, and acts as a state machine. It has an API for getting the allowed transitions:

$order_state = $order->getState();
print $order_state->value; // fulfillment
// Get the allowed transitions for the current state.
$transitions = $order_state->getTransitions();
// All transitions have a translatable label that can be shown in the UI (great for action buttons)
print_r($transitions['completed']->getLabel());
// Same as $order_state->value = 'completed';
$order_state->applyTransition($transitions['complete']);

An entity can have multiple workflows, each in its own state field. An order might have checkout and payment workflows. A node might have legal and marketing workflows. Workflow groups are used to group workflows used for the same purpose (e.g. payment workflows).


See the README for a full architecture overview.

Drupal 7

The State Flow submodule provides a base implementation of the State Machine class. It provides a base workflow as a base plugin.

Custom plugins should use State Flow as a model when:

  • Adding new states
  • Adding new events

State Flow provides the following optional integration with other modules:

  • Rules: Hook a condition into a event transition
  • Views: Exposes defined states, revision information, and timestamps

There are two active branches:

7.x-2.x

  • Extend State Flow by hook_state_flow_machine_type_alter() instead of variable_set
  • Bulk revision editing
  • Workflow scheduling. Requires Date_Popup.
  • Easily implement conditions to allow workflow to be ignored

7.x-3.x

Currently in unstable development as a collaborative effort with Workbench Moderation. State Flow will become State Flow Node. An entity agnostic State Flow Entity will be created. State Flow Node will be dependent on State Flow Entity.
Uses Drafty to ensure consistent revision handling.
More info on 3.x #1587574: [META] Merge changes from 2.x and 3.x

Development sponsored by Energy.gov

This module was also made with PHPStorm, an awesome IDE from Jetbrains that provides licenses supporting open source projects and Navicat, an equally awesome database management GUI.

Depends on

Dependencies of the latest stable release

  • options Drupal core

Required by

14 tracked projects depend on this one

Activity

Tracked releases
2
Tracked since
May 2025
Latest release
6 months ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Core Release date
8.x-1.14 Stable 9–11 Feb 12, 2026
8.x-1.13 Stable 9–11 May 5, 2025