getDataBag example


    }

    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;
    }

    public function onMailBeforeSentEvent(MailBeforeSentEvent $event): ?MailBeforeSentEvent
    {
        $data = $event->getData();

        
$request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT, $context);
        $request->attributes->set(RequestTransformer::STOREFRONT_URL, 'shopware.test');
        $request->setSession($this->getSession());

        $this->getContainer()->get('request_stack')->push($request);

        $customer1 = $context->getCustomer();
        static::assertNotNull($customer1);
        $oldBillingAddressId = $customer1->getDefaultBillingAddressId();
        $oldShippingAddressId = $customer1->getDefaultShippingAddressId();

        $dataBag = $this->getDataBag('billing');
        $controller->addressBook($request$dataBag$context$customer1);
        $customer = $this->customerRepository->search(new Criteria([$customerId])$context->getContext())->first();
        static::assertInstanceOf(CustomerEntity::class$customer);

        static::assertNotSame($oldBillingAddressId$customer->getDefaultBillingAddressId());
        static::assertSame($oldShippingAddressId$customer->getDefaultShippingAddressId());
    }

    public function testCreateShippingAddressIsNewSelectedAddress(): void
    {
        [$customerId] = $this->createCustomers();

        
static::assertEquals($context, Context::createDefaultContext());
    }

    public function testGetDataBag(): void
    {
        $mailTemplate = new MailTemplateEntity();
        $flowEvent = $this->createMock(StorableFlow::class);

        $expectDataBag = new DataBag(['data' => 'data']);
        $event = new FlowSendMailActionEvent($expectDataBag$mailTemplate$flowEvent);
        $actualDataBag = $event->getDataBag();

        static::assertEquals($actualDataBag$expectDataBag);
    }

    public function testGetMailTemplate(): void
    {
        $mailTemplate = new MailTemplateEntity();
        $flowEvent = $this->createMock(StorableFlow::class);

        $event = new FlowSendMailActionEvent(new DataBag()$mailTemplate$flowEvent);

        
Home | Imprint | This part of the site doesn't use cookies.