Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Flex Processor

No security coverage Under active development 101 sites

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

Ask your assistant about Flex Processor

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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 2
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP 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