Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

This module provides a way to use services when preprocess entities.
It does this by adding a service pass and provider.

It is built for developers and doesn't add any special functionality
out of the box.

The module will however be able to call services out of the box for nodes and paragraphs.
But can easily be used for all entities.

You just have to call the following function:
_entity_preprocess_services_preprocess_entity

See configuration on how to use this.

CONFIGURATION

-------------
You can add preprocess services for nodes and paragraphs out of the box.
A preprocess service will be picked up by "tagging" it.

See example module file on how this works:
entity_preprocess_services_example.services.yml

You tag a service as a "preprocess service" by adding this to your service:

tags:
  - { name: entity_preprocess_service, priority: 100 }

Priority can be used to establish the order of preprocess services.

You can then specify for which entities this service must be called.
You do this by adding following to your service:

properties:
      applies_to:
        - { entity_type: 'node', view_mode: 'full'}

There are 3 properties that can be added:
- entity_type: type of entity (getEntityTypeId())
- bundle: for what bundle? (bundle())
- view_mode: for what view mode?

A full service would look like this:

entity_preprocess_services_example.preprocess_service.node.full:
class: Drupal\entity_preprocess_services_example\PreprocessService\ExampleNodeFullPreprocessService
tags:
  - { name: entity_preprocess_service, priority: 100 }
properties:
  applies_to:
    - { entity_type: 'node', view_mode: 'full', bundle: 'page'}

This service will call the preprocess function for nodes of type page in
the full view mode.

Out of the box, it only works for nodes and paragraphs.
However, you can quickly use this for other / entities or custom entities.

Simply call the function: _entity_preprocess_services_preprocess_entity

Pass 3 arguments:
- the variables array
- the entity
- the view mode

The function will do the rest.

/**
 * Implements hook_preprocess_paragraph().
 */
function entity_preprocess_services_preprocess_paragraph(array &$variables) {
  /** @var \Drupal\paragraphs\ParagraphInterface $paragraph */
  $paragraph = $variables['paragraph'];

  _entity_preprocess_services_preprocess_entity(
    $variables,
    $paragraph,
    $variables['elements']['#view_mode']
  );
}

EXCLUDING ENTITIES

----------
It's possible to exclude certain entity types from a service.
You can do this with the "excludes" key under properties.

For example, you want to preprocess all nodes except "news teasers".
Your service definition can look as follows:

entity_preprocess_services_example.preprocess_service.node.full:
class: Drupal\entity_preprocess_services_example\
PreprocessService\ExampleNodeFullPreprocessService
tags:
  - { name: entity_preprocess_service, priority: 100 }
properties:
  applies_to:
    - { entity_type: 'node', view_mode: 'full'}
  excludes:
   -  { entity_type: 'node',  bundle: 'news'}

Activity

Total releases
3
First release
Jul 2025
Latest release
8 months ago
Release cadence
4 days
Stability
67% stable

Release Timeline

Releases

Version Type Release date
3.0.4 Stable Jul 24, 2025
3.0.x-dev Dev Jul 24, 2025
3.0.3 Stable Jul 17, 2025