Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows developers to integrate custom services into entity pre-processing. It provides a framework for defining services that can be automatically triggered during the rendering process for specific entity types, bundles, and view modes, with built-in support for nodes and paragraphs.

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
11 months ago
Releases (12 mo)
2 ▲ from 1
Maintenance
Slowing

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