getUserLocale example

->method('dispatch')
            ->with(static::callback(function DWebhookEventMessage $message) use ($payload$appId$webhookId$shopwareVersion) {
                $actualPayload = $message->getPayload();
                static::assertArrayHasKey('eventId', $actualPayload['source']);
                unset($actualPayload['source']['eventId']);
                static::assertEquals($payload$actualPayload);
                static::assertEquals($appId$message->getAppId());
                static::assertEquals($webhookId$message->getWebhookId());
                static::assertEquals($shopwareVersion$message->getShopwareVersion());
                static::assertEquals('s3cr3t', $message->getSecret());
                static::assertEquals(Defaults::LANGUAGE_SYSTEM, $message->getLanguageId());
                static::assertEquals('en-GB', $message->getUserLocale());

                return true;
            }))
            ->willReturn(new Envelope(new WebhookEventMessage($webhookEventId$payload$appId$webhookId, '6.4', 'http://test.com', 's3cr3t', Defaults::LANGUAGE_SYSTEM, 'en-GB')));

        $webhookDispatcher = new WebhookDispatcher(
            $this->getContainer()->get('event_dispatcher'),
            $this->getContainer()->get(Connection::class),
            $client,
            $this->shopUrl,
            $this->getContainer(),
            
$timestamp = time();
        $payload['timestamp'] = $timestamp;

        /** @var string $jsonPayload */
        $jsonPayload = json_encode($payload, \JSON_THROW_ON_ERROR);

        $headers = ['Content-Type' => 'application/json',
            'sw-version' => $shopwareVersion];

        // LanguageId and UserLocale will be required from 6.5.0 onward         if ($message->getLanguageId() && $message->getUserLocale()) {
            $headers = array_merge($headers[AuthMiddleware::SHOPWARE_CONTEXT_LANGUAGE => $message->getLanguageId(), AuthMiddleware::SHOPWARE_USER_LANGUAGE => $message->getUserLocale()]);
        }

        $requestContent = [
            'headers' => $headers,
            'body' => $jsonPayload,
            'connect_timeout' => self::CONNECT_TIMEOUT,
            'timeout' => self::TIMEOUT,
        ];

        if ($message->getSecret()) {
            
Home | Imprint | This part of the site doesn't use cookies.