Skip to content

Step dependencies

Latest
Compare
Choose a tag to compare
@wol-soft wol-soft released this 21 Apr 09:06
· 5 commits to main since this release
48c6886

Each workflow step implementation can now define step dependencies which are evaluated before the step is executed:

public function run(
    \PHPWorkflow\WorkflowControl $control,
    // The key customerId must contain a string
    #[\PHPWorkflow\Step\Dependency\Required('customerId', 'string')]
    // The customerAge must contain an integer. But also null is accepted.
    // Each type definition can be prefixed with a ? to accept null.
    #[\PHPWorkflow\Step\Dependency\Required('customerAge', '?int')]
    // Objects can also be type hinted
    #[\PHPWorkflow\Step\Dependency\Required('created', \DateTime::class)]
    \PHPWorkflow\State\WorkflowContainer $container,
) {
    // Implementation which can rely on the defined keys to be present in the container.
}

See the Readme for more details.