Copied!

WorkflowResolverInterface

WorkflowResolverInterface.php : 52

Resolves workflow for a given subject.

Is intended to be implemented as a decorator.

The following example assigns the 'workflow_with_audit' workflow to payment above 100000€, and passes others to the default workflow resolver:

final class WorkflowResolver implements WorkflowResolverInterface
{
    public function __construct(
         private WorkflowResolverInterface $innerWorkflowResolver
         private Registry $workflowRegistry
     ) {

     }

    public function resolveWorkflow(WorkflowSubjectInterface $subject): WorkflowInterface
    {
         if ($subject instanceof PaymentInterface || $subject instanceof PaymentCreateStruct) {
             if ($payment->getAmount()->greaterThan(Money::EUR(100000)) {
                 return $this->workflowRegistry->get($subject, 'workflow_with_audit');
             }
         }

         return $this->innerWorkflowResolver->resolveWorkflow($subject);
    }
}

and related service definition:

services:
   App\Payment\Workflow\WorkflowResolver:
     decorates: Ibexa\Contracts\Payment\Payment\Workflow\WorkflowResolverInterface

Methods

publicresolveWorkflow()

WorkflowResolverInterface.php : 54
public resolveWorkflow(WorkflowSubjectInterface $subject) : WorkflowInterface

Parameters

Name Type Default value Description
$subject WorkflowSubjectInterface - -

Return values

WorkflowInterface