Skip to content

Get next incremental ID

Version v2

Instead of downloading the archive, you can download and apply this model as a recipe (Drupal 10.3 or later):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Import recipe
composer require drupal-eca-recipe/eca_lib_0011

# Enable recipe with Drush (requires version 13 or later):
drush recipe ../recipes/eca_lib_0011

# Enable recipe without Drush:
cd web && php core/scripts/drupal recipe ../recipes/eca_lib_0011

# Rebuilding caches is optional, sometimes required:
drush cr

Purpose

This model increments a sidewide ID by 1 and returns that on screen. It uses Drupal's state service to store the value inbetween requests.

Dependencies

  • module
    • eca_base
    • eca_tamper

Used plugins

Events

Actions

Changelog

v1

Initial version

v2

Add an "Acquire lock" action to make sure it still works with concurrent users.