getFlowState example


        yield 'mixed cart' => [
            [
                ['baz.pdf'],
                [],
            ],
        ];
    }

    public function onFlowSendMailActionEvent(FlowSendMailActionEvent $event): ?FlowSendMailActionEvent
    {
        $sequence = $event->getStorableFlow()->getFlowState()->currentSequence;

        if ($sequence instanceof ActionSequence && $sequence->action !== 'action.grant.download.access') {
            return null;
        }

        $event->getDataBag()->add([
            'contentHtml' => str_replace('frontend.account.order.single.download', 'store-api.account.order.single.download', (string) $event->getDataBag()->get('contentHtml')),
            'contentPlain' => str_replace('frontend.account.order.single.download', 'store-api.account.order.single.download', (string) $event->getDataBag()->get('contentPlain')),
        ]);

        return $event;
    }
static::assertEquals(Context::createDefaultContext()$this->storableFlow->getContext());
    }

    public function testGetConfig(): void
    {
        static::assertEquals(['config' => 'value']$this->storableFlow->getConfig());
    }

    public function testGetFlowState(): void
    {
        static::expectException(FlowException::class);
        $this->storableFlow->getFlowState();

        $this->storableFlow->setFlowState(new FlowState());

        static::assertEquals(new FlowState()$this->storableFlow->getFlowState());
    }

    public function testStop(): void
    {
        static::expectException(FlowException::class);
        $this->storableFlow->stop();

        
'SELECT 1 FROM mail_template_type_translation WHERE language_id = :languageId AND mail_template_type_id =:mailTemplateTypeId',
            [
                'languageId' => Uuid::fromHexToBytes($context->getLanguageId()),
                'mailTemplateTypeId' => Uuid::fromHexToBytes($mailTemplate->getMailTemplateTypeId()),
            ]
        );

        if (!$mailTemplateTypeTranslation) {
            // Don't throw errors if this fails // Fix with NEXT-15475             $this->logger->error(
                "Could not update mail template type, because translation for this language does not exits:\n"
                . 'Flow id: ' . $event->getFlowState()->flowId . "\n"
                . 'Sequence id: ' . $event->getFlowState()->getSequenceId()
            );

            return;
        }

        $this->mailTemplateTypeRepository->update([[
            'id' => $mailTemplate->getMailTemplateTypeId(),
            'templateData' => $templateData,
        ]]$context);
    }

    
return;
            }
        }
    }

    public function executeSequence(?Sequence $sequence, StorableFlow $event): void
    {
        if ($sequence === null) {
            return;
        }

        $event->getFlowState()->currentSequence = $sequence;

        if ($sequence instanceof IfSequence) {
            $this->executeIf($sequence$event);

            return;
        }

        if ($sequence instanceof ActionSequence) {
            $this->executeAction($sequence$event);
        }
    }

    
$rule = new OrderTagRule(Rule::OPERATOR_EQ, [$tagId]);
        $ruleEntity = new RuleEntity();
        $ruleEntity->setId($ruleId);
        $ruleEntity->setPayload($rule);
        $ruleEntity->setAreas([RuleAreas::FLOW_AREA]);
        $ruleLoader->method('load')->willReturn(new RuleCollection([$ruleEntity]));

        $flowExecutor = new FlowExecutor($eventDispatcher$appFlowActionProvider$ruleLoader$scopeBuilder[]);
        $flowExecutor->executeIf($ifSequence$flow);

        static::assertEquals($trueCaseSequence$flow->getFlowState()->currentSequence);
    }
}
Home | Imprint | This part of the site doesn't use cookies.