Important
You are browsing upcoming documentation for version 6.1 of OroCommerce, scheduled for release in 2025. Read the documentation for version 6.0 (the latest LTS version) to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Managing Workflow Elements
Transition Conditions
Add a Custom Condition
Conditions are based on the ConfigExpression component.
To add a custom condition, add a service to DIC with tag oro_action.condition, as illustrated below:
services:
Oro\Bundle\WorkflowBundle\ConfigExpression\Blank:
tags:
- { name: oro_action.condition, alias: blank|empty }
Symbol “|” in alias can be used to have several aliases. Please keep in mind that service class must implement Oro\Component\ConfigExpression\ExpressionInterface.
Configurable Condition
Alias: configurable
Description: Uses Condition Assembler to assemble conditions from passed configuration. This condition is NOT intended to be used in the configuration of Workflow but it can be used to create a condition based on the configuration in runtime.
Options:
Valid configuration of conditions.
Code Example
If value of attribute “call_timeout” is not blank AND equals 20.
$configuration = [
'@and' => [
'@not_blank' => ['$call_timeout'],
'@equal' => ['$call_timeout', 20]
]
];
/** @var \Oro\Bundle\WorkflowBundle\Model\Condition\ConditionFactory $conditionFactory */
$condition = $conditionFactory->create(Configurable::ALIAS, $configuration);
/** @var object $data */
$data->call_timeout = 20;
var_dump($condition->evaluate($data)); // will output TRUE
Transition Actions
Add a Custom Action
To add a custom action, add a service to DIC with tag oro_action.action, as illustrated below:
services:
Oro\Component\Action\Action\CloseWorkflow:
tags:
- { name: oro_action.action, alias: close_workflow }
Symbol “|” in alias can be used to have several aliases. Please keep in mind that the service class must implement Oro\Component\ActionAction\ActionInterface.
Configuration Syntax
Each action can be optionally configured with a condition. It allows to implement more sufficient logic in the definitions of transitions. If a condition is not satisfied, the action will not be executed.
If flag break_on_failure is specified, the action throws an exception on error; otherwise it logs error using a standard logger.
Syntax examples are provided below:
Full Configuration Example
- '@alias_of_action':
conditions:
# optional condition configuration
parameters:
- some_parameters: some_value
# other parameters of action
break_on_failure: boolean # by default false
Short Configuration Example
- '@alias_of_action':
- some_parameters: some_value
# other parameters of action