Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Flex Processor

101 sites No security coverage
View on drupal.org

Flex Processor is a Drupal module that allows developers to attach customizable processing plugins to various data structures. This enables dynamic manipulation and transformation of data, streamlining API responses and simplifying development by allowing quick definitions of processor logic.

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

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Oct 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 4
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.0-beta4 Pre-release 10–11 Jun 13, 2025
1.0.0-beta3 Pre-release 10–11 Jun 12, 2025
1.0.0-beta2 Pre-release 10–11 Oct 4, 2024
1.0.0-beta1 Pre-release 10–11 Oct 4, 2024