addDomain example

return [
            new TwigFunction('rawUrl', $this->rawUrl(...)),
        ];
    }

    public function rawUrl(string $name, array $parameters = [], ?string $domain = null): string
    {
        $request = $this->stack->getMainRequest();
        if (!$request) {
            $url = $this->router->generate($name$parameters);

            return $this->addDomain($url$domain);
        }

        $attribute = $request->attributes->get('sw-sales-channel-base-url');
        $request->attributes->set('sw-sales-channel-base-url', '');

        $url = $this->router->generate($name$parameters);

        $request->attributes->set('sw-sales-channel-base-url', $attribute);

        return $this->addDomain($url$domain);
    }

    
static::assertSame('danger', $type);
    }

    private function createRequest(): Request
    {
        $request = new Request();
        $request->setSession($this->getSession());

        $session = $request->getSession();
        $session->set(PlatformRequest::HEADER_CONTEXT_TOKEN, Random::getAlphanumericString(32));

        $this->addDomain($this->domain);
        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);
        $request->headers->set(PlatformRequest::HEADER_CONTEXT_TOKEN, Random::getAlphanumericString(32));
        $request->attributes->add([RequestTransformer::STOREFRONT_URL => $this->domain]);
        $request->attributes->add([PlatformRequest::ATTRIBUTE_CONTEXT_OBJECT => $salesChannelContext]);
        $request->attributes->add([PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID => TestDefaults::SALES_CHANNEL]);
        $request->attributes->add(['_route' => 'frontend.account.register.page', SalesChannelRequest::ATTRIBUTE_IS_SALES_CHANNEL_REQUEST => true]);
        $request->attributes->add([RequestTransformer::STOREFRONT_URL, 'shopware.test']);

        return $request;
    }

    


    /** * @param array{domain: string, expectDomain: string} $domainUrlTest * * @dataProvider sendMailWithDomainAndLeadingSlashProvider */
    public function testSendMailWithDomainAndLeadingSlash(array $domainUrlTest): void
    {
        $this->createCustomer('foo-test@test.de');

        $this->addDomain($domainUrlTest['domain']);

        $caughtEvent = null;
        $this->addEventListener(
            $this->getContainer()->get('event_dispatcher'),
            CustomerAccountRecoverRequestEvent::EVENT_NAME,
            static function DCustomerAccountRecoverRequestEvent $event) use (&$caughtEvent): void {
                $caughtEvent = $event;
            }
        );

        $this->browser
            
Home | Imprint | This part of the site doesn't use cookies.