Skip to main content
Version: 2024.4

Support Strategies

The workflow engine offers several different ways to define which entities are supported by the configured workflow.

Important: The different configuration ways cannot be combined. It's necessary to choose one.

Supports

The simplest way is to use supports. A single entity class name or an array of entity class names can be defined.

Configuration Examples
   supports: Pimcore\Model\DataObject\Product
   supports:
- Pimcore\Model\DataObject\Product
- Pimcore\Model\DataObject\ProductCategory

Expression Support Strategy

The expression support strategy can be used if a workflow should apply to a entity under certain circumstances only. It's possible to define a symfony expression - the workflow then applies only if the expression is valid.

Configuration Example

In the following example the workflow applies to products where the attribute "productType" is equal to "article".

   support_strategy:
type: expression
arguments:
- Pimcore\Model\DataObject\Product
- "subject.getProductType() == 'article'"

Custom Support Strategy

If a very specific logic is needed it's possible to add a service which implements the Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface.

Configuration Example
   support_strategy:
service: App\Workflow\SupportStrategy
Example Implementation (needs to be registered 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;
}
}