custom/plugins/WbfkExtensions/src/Core/Content/Flow/Dispatching/Action/GenerateDocumentAction.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace WbfkExtensions\Core\Content\Flow\Dispatching\Action;
  4. use Shopware\Core\Content\Flow\Dispatching\StorableFlow;
  5. use Shopware\Core\Framework\Context;
  6. use Shopware\Core\Framework\Event\FlowEvent;
  7. use Shopware\Core\Framework\Struct\ArrayStruct;
  8. class GenerateDocumentAction extends \Shopware\Core\Content\Flow\Dispatching\Action\GenerateDocumentAction
  9. {
  10.     public const CREATE_DOCUMENTS_EXTENSION 'create-documents';
  11.     public function __construct(
  12.         private readonly \Shopware\Core\Content\Flow\Dispatching\Action\GenerateDocumentAction $decorated,
  13.     ) {
  14.     }
  15.     /**
  16.      * @deprecated tag:v6.5.0 Will be removed, implement handleFlow instead
  17.      */
  18.     public function handle(FlowEvent $event): void
  19.     {
  20.         if ($this->skipDocumentGeneration($event->getContext())) {
  21.             return;
  22.         }
  23.         $this->decorated->handle($event);
  24.     }
  25.     public function handleFlow(StorableFlow $flow): void
  26.     {
  27.         if ($this->skipDocumentGeneration($flow->getContext())) {
  28.             return;
  29.         }
  30.         $this->decorated->handleFlow($flow);
  31.     }
  32.     protected function skipDocumentGeneration(Context $context): bool
  33.     {
  34.         /** @var ArrayStruct $conf */
  35.         $conf $context->getExtension(self::CREATE_DOCUMENTS_EXTENSION);
  36.         if (!$conf) {
  37.             return false;
  38.         }
  39.         return $conf->get('skip') ?? false;
  40.     }
  41. }