Skip to content

Node processors

Both processors extend FlowDrop's AbstractFlowDropNodeProcessor and are registered with the #[FlowDropNodeProcessor] attribute. For what they do from a workflow builder's point of view, see Building a workflow.

FieldContentProcessor

  • Plugin ID: field_content_processor. Node type: flowdrop_field_widget_actions_field_content_processor.
  • Services: entity_type.manager, flowdrop.entity_serializer.
  • Validation: fails unless entity_values or entity_id is non-empty.

Processing order:

  1. Load the entity when entity_type and entity_id are set. Entities the current user cannot view are treated as not found.
  2. If entity_values is set, extract from it, then replace labels with field definition labels when the entity loaded.
  3. Otherwise extract from the loaded entity through EntitySerializer, skipping computed fields.
  4. Build formatted_context and collect file_ids from every fids array in entity_values.

entity_info.is_new is TRUE whenever no entity was loaded, which includes existing entities the user cannot view.

FieldSuggestionOutput

  • Plugin ID: field_suggestion_output. Node type: flowdrop_field_widget_actions_field_suggestion_output.
  • Validation: fails with MISSING_CONTENT when content is empty.
  • Conversion uses League\CommonMark\CommonMarkConverter for html and plain.

Writing your own output node

A custom node works with the actions if it returns either:

  • the key configured as the action's Output Key, with a string value (non-string values are cast with (string)), or
  • no_match set to a truthy value, to tell the editor there is nothing to suggest.

For entity reference fields, return the Name (ID), Name (ID) format.

#[FlowDropNodeProcessor(
  id: 'my_term_suggestions',
  label: new TranslatableMarkup('My term suggestions'),
  description: 'Returns matching terms as autocomplete entries',
  version: '1.0.0',
)]
final class MyTermSuggestions extends AbstractFlowDropNodeProcessor {

  public function process(ParameterBagInterface $params): array {
    $terms = $this->findTerms($params->getString('text', ''));
    if ($terms === []) {
      return ['no_match' => TRUE];
    }
    $entries = array_map(
      static fn ($term) => sprintf('%s (%d)', $term->label(), $term->id()),
      $terms,
    );
    return ['processed_content' => implode(', ', $entries)];
  }

}

To show the node in the editor, also ship a flowdrop_node_type config entity for it, following the two in this module's config/install.