Support Strategies
The workflow engine offers several ways to define which entities a configured workflow supports.
The different configuration methods cannot be combined. Choose one.
Supports
Use supports to define a single entity class name or an array of entity class names.
Configuration Examples
supports: Pimcore\Model\DataObject\Product
supports:
- Pimcore\Model\DataObject\Product
- Pimcore\Model\DataObject\ProductCategory
Expression Support Strategy
The expression support strategy applies a workflow to an entity only under certain circumstances. Define a Symfony expression - the workflow applies only when the expression evaluates to true.
A blank expression (empty or whitespace only) is not evaluated: the workflow then applies to every entity of the configured class name(s). Make sure an expression that is built from a parameter or environment variable is not blank unintentionally, otherwise the workflow applies to all entities of the class.
Configuration Example
In the following example, the workflow applies to products where the attribute "productType" equals "article".
support_strategy:
type: expression
arguments:
- Pimcore\Model\DataObject\Product
- "subject.getProductType() == 'article'"
Custom Support Strategy
For custom logic, add a service that implements
Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface.
Configuration Example
support_strategy:
service: App\Workflow\SupportStrategy
Example Implementation (register in the service container)
<?php
namespace App\Workflow;
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
use Symfony\Component\Workflow\WorkflowInterface;
class SupportStrategy implements WorkflowSupportStrategyInterface
{
public function supports(WorkflowInterface $workflow, object $subject): bool
{
if ($subject instanceof \Pimcore\Model\DataObject\Test) {
return true;
}
return false;
}
}