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).

flex_processor

70 sites No security coverage
View on drupal.org

Flex Processor is a versatile Drupal module designed to empower developers with the ability to seamlessly attach customizable processor plugins to various data structures. This tool allows developers to define specific processing workflows for their data, enabling dynamic manipulation and transformation.

Features

Key Features:

  • Customizable Processors: Easily create and attach processors tailored to unique data needs, providing flexibility in data handling.
  • Data Manipulation: Reduce, modify, update, or transform data as required, ensuring the output meets specific requirements.
  • API Response Structuring: Streamline API responses by processing the output efficiently, enhancing integration and performance.
  • Context-Agnostic Application: While optimized for API use, Flex Processor can be applied in diverse contexts where data transformation is necessary.
  • Developer-Friendly: Simplifies the development process, allowing quick definitions of processor logic without extensive overhead.
  • With Flex Process, developers gain a powerful tool that enhances data flexibility and responsiveness, making it easier to create robust, adaptable


Post-Installation

After installing the module, you will be able to create processors plugins and process data with them

<?php
namespace Drupal\your_module\Plugin\EntityDataProcessor;

use Drupal\flex_processor\Plugin\EntityDataProcessor;

/**
 * Returns the structured data of an entity.
 *
 * @DataProcessor(
 *   id = "node__article__card",
 *   label = @Translation("Node: Article Card"),
 *   type = "node",
 *   bundles = {
 *     "article"
 *   },
 *   variant = "card"
 * )
 */
class ArticleCard extends EntityDataProcessor {

  /**
   * {@inheritdoc}
   */
  public function process(mixed $entity, array $options = []): mixed {

    return [
      'title' => $entity->getTitle(),
      'type' => $entity->getType(),
      'url' => $entity->toUrl()->toString(TRUE)->getGeneratedUrl(),
      'fields' => [
        'summary' => $this->dataProcessorManager->process(
          $entity->get('body'),
         ),
        'image' => $this->dataProcessorManager->process(
          $entity->get('field_media'),
          ['style' => 'article_card_400x300'],
        )
      ]
    ];
  }
}

And this processor can be trigger with

<?php
  $article = \Drupal::entityTypeManager()->getStorage('node')->load($aid);
  $data = \Drupal::service('plugin.manager.flex_processor')->process(
    $article, 
    ['variant' => 'card'],
  );
  echo json_encode($data);

output

  {
    "title" : "Title A",
    "type" : "article",
    "url" : "https://example.com/article/title-a",
    "fields" : {
      "summary" : "Bla bla bla bla...",
      "image" : "https://example.com/site/default/files/styles/article_card_400x300/public/2024-10/image-a.png",
    }
  }


Read the readme.md file for more examples

Activity

Total releases
2
First release
Jun 2025
Latest release
10 months ago
Release cadence
1 day
Stability
0% stable

Releases

Version Type Release date
1.0.0-beta4 Pre-release Jun 13, 2025
1.0.0-beta3 Pre-release Jun 12, 2025