feature: Add string-based node keys support to Workflow system #275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces string-based node keys to the Workflow system, allowing developers to use custom string identifiers for nodes instead of being limited to class names. This enables
workflows to have multiple instances of the same node class - a critical feature for building complex, reusable workflows.
Key Features
'add1','multiply_first'instead of class namesTechnical Changes
Workflow::getNodes()to detect and handle associative arrays with string keysWorkflow::addNode()to accept an optional string key parameter (defaults to class name)Workflow::addNodes()to handle both indexed and associative arraysMermaidExporterto intelligently handle both class names and string keysWorkflowStringKeysTest.phpBackward Compatibility
All existing workflows continue to function exactly as before. The system automatically detects the array format:
Example Usage
Basic Calculator Workflow with String Keys
Benefits
Testing
Migration Guide
No migration needed! Existing workflows continue to work as-is. To adopt string keys:
Related Issues
Addresses the limitation where workflows couldn't have multiple instances of the same node class