You are browsing the documentation for version 3.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation 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:

1 services:
2     Oro\Bundle\WorkflowBundle\ConfigExpression\Blank:
3         tags:
4             - { 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.

 1 $configuration = array(
 2     '@and' => array(
 3         '@not_blank' => array('$call_timeout'),
 4         '@equal' => array('$call_timeout', 20)
 5     )
 6 );
 7 /** @var $conditionFactory \Oro\Bundle\WorkflowBundle\Model\Condition\ConditionFactory */
 8 $condition = $conditionFactory->create(Configurable::ALIAS, $configuration);
10 /** @var object $data */
11 $data->call_timeout = 20;
13 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:

1 services:
2     Oro\Component\Action\Action\CloseWorkflow:
3         tags:
4             - { 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

1 - @alias_of_action:
2     conditions:
3         # optional condition configuration
4     parameters:
5         - some_parameters: some_value
6         # other parameters of action
7     break_on_failure: boolean # by default false

Short Configuration Example

1 - @alias_of_action:
2     - some_parameters: some_value
3     # other parameters of action