<?php
declare(strict_types=1);
namespace WbfkExtensions\Core\Content\Flow\Dispatching\Action;
use Shopware\Core\Content\Flow\Dispatching\StorableFlow;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Event\FlowEvent;
use Shopware\Core\Framework\Struct\ArrayStruct;
class GenerateDocumentAction extends \Shopware\Core\Content\Flow\Dispatching\Action\GenerateDocumentAction
{
public const CREATE_DOCUMENTS_EXTENSION = 'create-documents';
public function __construct(
private readonly \Shopware\Core\Content\Flow\Dispatching\Action\GenerateDocumentAction $decorated,
) {
}
/**
* @deprecated tag:v6.5.0 Will be removed, implement handleFlow instead
*/
public function handle(FlowEvent $event): void
{
if ($this->skipDocumentGeneration($event->getContext())) {
return;
}
$this->decorated->handle($event);
}
public function handleFlow(StorableFlow $flow): void
{
if ($this->skipDocumentGeneration($flow->getContext())) {
return;
}
$this->decorated->handleFlow($flow);
}
protected function skipDocumentGeneration(Context $context): bool
{
/** @var ArrayStruct $conf */
$conf = $context->getExtension(self::CREATE_DOCUMENTS_EXTENSION);
if (!$conf) {
return false;
}
return $conf->get('skip') ?? false;
}
}