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_valuesorentity_idis non-empty.
Processing order:
- Load the entity when
entity_typeandentity_idare set. Entities the current user cannot view are treated as not found. - If
entity_valuesis set, extract from it, then replace labels with field definition labels when the entity loaded. - Otherwise extract from the loaded entity through
EntitySerializer, skipping computed fields. - Build
formatted_contextand collectfile_idsfrom everyfidsarray inentity_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_CONTENTwhencontentis empty. - Conversion uses
League\CommonMark\CommonMarkConverterforhtmlandplain.
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_matchset 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.