getLanguageId example

'state_machine_id' => Uuid::fromHexToBytes($machineId),
                'from_state_id' => Uuid::fromHexToBytes($from),
                'to_state_id' => Uuid::fromHexToBytes($to),
                'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ]
        );
    }

    private function insertTranslations(string $stateId, Connection $connection): void
    {
        $languages = [Defaults::LANGUAGE_SYSTEM => 'Unconfirmed'];
        if (($enGbId = $this->getLanguageId('en-GB', $connection)) !== null) {
            $languages[$enGbId] = 'Unconfirmed';
        }
        if (($deDeId = $this->getLanguageId('de-DE', $connection)) !== null) {
            $languages[$deDeId] = 'UnbestÃĪtigt';
        }

        foreach ($languages as $languageId => $name) {
            $connection->executeStatement(
                'REPLACE INTO state_machine_state_translation (`language_id`, `state_machine_state_id`, `name`, `created_at`) VALUES (:language_id, :state_machine_state_id, :name, :created_at)',
public function filterByMediaId(string $id): self
    {
        return $this->filter(fn (MediaTranslationEntity $mediaTranslation) => $mediaTranslation->getMediaId() === $id);
    }

    /** * @return list<string> */
    public function getLanguageIds(): array
    {
        return $this->fmap(fn (MediaTranslationEntity $mediaTranslation) => $mediaTranslation->getLanguageId());
    }

    public function filterByLanguageId(string $id): self
    {
        return $this->filter(fn (MediaTranslationEntity $mediaTranslation) => $mediaTranslation->getLanguageId() === $id);
    }

    public function getApiAlias(): string
    {
        return 'media_translation_collection';
    }

    
return new ContextTokenResponse($context->getToken()$changeUrl);
    }

    /** * @param array<mixed> $parameters */
    private function checkNewDomain(array $parameters, SalesChannelContext $context): ?string
    {
        if (
            !isset($parameters[self::LANGUAGE_ID])
            || $parameters[self::LANGUAGE_ID] === $context->getLanguageId()
        ) {
            return null;
        }

        $domains = $context->getSalesChannel()->getDomains();
        if ($domains === null) {
            return null;
        }

        $langDomain = $domains->filterByProperty('languageId', $parameters[self::LANGUAGE_ID])->first();
        if ($langDomain === null) {
            
public function get(SalesChannelContextServiceParameters $parameters): SalesChannelContext
    {
        return Profiler::trace('sales-channel-context', function D) use ($parameters) {
            $token = $parameters->getToken();

            $session = $this->contextPersister->load($token$parameters->getSalesChannelId());

            if ($session['expired'] ?? false) {
                $token = Random::getAlphanumericString(32);
            }

            if ($parameters->getLanguageId() !== null) {
                $session[self::LANGUAGE_ID] = $parameters->getLanguageId();
            }

            if ($parameters->getCurrencyId() !== null && !\array_key_exists(self::CURRENCY_ID, $session)) {
                $session[self::CURRENCY_ID] = $parameters->getCurrencyId();
            }

            if ($parameters->getDomainId() !== null) {
                $session[self::DOMAIN_ID] = $parameters->getDomainId();
            }

            
$this->config = [];
    }

    /** * @param array<string> $ids * @param ProductEntity[] $existingProducts * * @return ProductEntity[] */
    private function updateLanguage(array $ids, Context $context, array $existingProducts): array
    {
        $configFields = $this->getConfigFields($context->getLanguageId());

        $versionId = Uuid::fromHexToBytes($context->getVersionId());
        $languageId = Uuid::fromHexToBytes($context->getLanguageId());

        $now = (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT);

        $this->delete($ids$context->getLanguageId()$context->getVersionId());

        $keywords = [];
        $dictionary = [];

        
if (Uuid::isValid($identifier)) {
            return $this->getLanguages()[mb_strtolower($identifier)]['id'] ?? null;
        }
        $mapping = $this->getLanguageCodeToIdMapping();

        return $mapping[mb_strtolower($identifier)] ?? null;
    }

    public static function createFromContext(Context $context): self
    {
        $self = new self($context);
        $self->set(LanguageDefinition::ENTITY_NAME, 'id', $context->getLanguageId());

        return $self;
    }

    public function set(string $entity, string $propertyName, string $value): void
    {
        $this->paths[$this->buildPathName($entity$propertyName)] = $value;
    }

    public function get(string $entity, string $propertyName): string
    {
        
$criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('name', 'system'));

        $result = $this->getContainer()->get('category_translation.repository')->search($criteria, Context::createDefaultContext());

        static::assertEquals(1, $result->getTotal());
        static::assertEquals(1, $result->count());

        /** @var CategoryTranslationEntity $translation */
        $translation = $result->first();
        static::assertEquals('system', $translation->getName());
        static::assertEquals(Defaults::LANGUAGE_SYSTEM, $translation->getLanguageId());
        static::assertEquals($id$translation->getCategoryId());
    }

    /** * @dataProvider casesToManyPaginated * * @param list<array<string, mixed>> $data * @param callable(Criteria): void $modifier * @param list<string> $expected */
    public function testLoadToManyPaginated(array $data, callable $modifier, array $expected): void
    {
unset($payload['source']['eventId']);
        static::assertEquals([
            'foo' => 'bar',
            'source' => [
                'url' => 'https://example.com',
                'appVersion' => $webhookEntity->getApp()?->getVersion(),
                'shopId' => 'foobar',
                'action' => $event->getName(),
            ],
        ]$payload);

        static::assertEquals($message->getLanguageId(), Defaults::LANGUAGE_SYSTEM);
        static::assertEquals($message->getAppId()$webhookEntity->getApp()?->getId());
        static::assertEquals($message->getSecret()$webhookEntity->getApp()?->getAppSecret());
        static::assertEquals($message->getShopwareVersion(), '0.0.0');
        static::assertEquals($message->getUrl(), 'https://foo.bar');
        static::assertEquals($message->getWebhookId()$webhookEntity->getId());
    }

    private function getWebhookDispatcher(bool $isAdminWorkerEnabled): WebhookDispatcher
    {
        return new WebhookDispatcher(
            $this->dispatcher,
            
static::assertArrayHasKey('app_url', $shopConfig);
        $shopUrl = $shopConfig['app_url'];
        static::assertIsString($shopUrl);
        static::assertEquals($shopUrl$signedQuery['shop-url']);

        static::assertArrayHasKey('timestamp', $signedQuery);

        static::assertArrayHasKey('sw-version', $signedQuery);
        static::assertEquals($this->getContainer()->getParameter('kernel.shopware_version')$signedQuery['sw-version']);

        static::assertArrayHasKey('sw-context-language', $signedQuery);
        static::assertEquals(Context::createDefaultContext()->getLanguageId()$signedQuery['sw-context-language']);

        static::assertArrayHasKey('sw-user-language', $signedQuery);
        static::assertEquals('en-GB', $signedQuery['sw-user-language']);

        static::assertArrayHasKey('shopware-shop-signature', $signedQuery);
        static::assertEquals(
            hash_hmac('sha256', Uri::withoutQueryValue($signedUri, 'shopware-shop-signature')->getQuery()$this->secret),
            $signedQuery['shopware-shop-signature']
        );
    }
}
$homeUrlProvider = new HomeUrlProvider();

        static::assertCount(1, $homeUrlProvider->getUrls($this->salesChannelContext, 100)->getUrls());
    }

    public function testGetHomeUrlWithSalesChannelIsExistingOneDomain(): void
    {
        $criteria = new Criteria();
        $criteria->addAssociation('locale');
        $languages = $this->getContainer()->get('language.repository')->search($criteria$this->salesChannelContext->getContext())->getEntities();

        $languageId = $this->salesChannelContext->getLanguageId();
        $language = $languages->get($languageId);

        $domain = new SalesChannelDomainEntity();
        $domain->setId(Uuid::randomHex());
        $domain->setUrl('https://test-sitemap.de/en');
        $domain->setHreflangUseOnlyLocale(false);
        $domain->setLanguageId($language->getId());

        $this->salesChannelContext->getSalesChannel()->getDomains()->add($domain);

        $homeUrlProvider = new HomeUrlProvider();

        
new SitemapSalesChannelCriteriaEvent($criteria$context)
        );

        $salesChannels = $this->salesChannelRepository->search($criteria$context)->getEntities();

        /** @var SalesChannelEntity $salesChannel */
        foreach ($salesChannels as $salesChannel) {
            if ($salesChannel->getDomains() === null) {
                continue;
            }

            $languageIds = $salesChannel->getDomains()->map(fn (SalesChannelDomainEntity $salesChannelDomain) => $salesChannelDomain->getLanguageId());

            $languageIds = array_unique($languageIds);

            foreach ($languageIds as $languageId) {
                $this->messageBus->dispatch(new SitemapMessage($salesChannel->getId()$languageId, null, null, false));
            }
        }
    }
}

    protected function getPageLoader()
    {
        return $this->getContainer()->get(ProductPageLoader::class);
    }

    private function createReviews(ProductEntity $product, SalesChannelContext $context): void
    {
        $reviews = [];
        for ($i = 1; $i <= 5; ++$i) {
            $reviews[] = [
                'languageId' => $context->getContext()->getLanguageId(),
                'salesChannelId' => $context->getSalesChannel()->getId(),
                'productId' => $product->getId(),
                'title' => 'Test',
                'content' => 'test',
                'points' => $i,
                'status' => true,
            ];
        }

        $reviews[] = [
            'languageId' => $context->getContext()->getLanguageId(),
            
static::assertTrue($cart->has($productId));

        $orderId = $cartService->order($cart$salesChannelContextnew RequestDataBag());

        /** @var EntityRepository $orderRepository */
        $orderRepository = $this->getContainer()->get('order.repository');

        /** @var OrderEntity $order */
        $order = $orderRepository->search(new Criteria([$orderId])$salesChannelContext->getContext())->first();

        static::assertEquals($order->getLanguageId()$this->getDeDeLanguageId());
    }

    public function testOrderCartEn(): void
    {
        $context = Context::createDefaultContext();
        $customerId = $this->createCustomer($context);

        $cartService = $this->getContainer()->get(CartService::class);

        $options = [
            SalesChannelContextService::LANGUAGE_ID => Defaults::LANGUAGE_SYSTEM,
            

class ElasticsearchLanguageIndexIteratorMessageTest extends TestCase
{
    public function testMessage(): void
    {
        Feature::skipTestIfActive('ES_MULTILINGUAL_INDEX', $this);

        $msg = new ElasticsearchLanguageIndexIteratorMessage('1');

        static::assertSame('1', $msg->getLanguageId());
    }
}
/** * @param SubscribeRequest $data * * @return array{id: string, languageId: string, salesChannelId: string, status: string, hash: string, email: string, storefrontUrl: string, firstName?: string, lastName?: string, zipCode?: string, city?: string, street?: string, salutationId?: string} */
    private function completeData(array $data, SalesChannelContext $context): array
    {
        $id = $this->getNewsletterRecipientId($data['email']$context);

        $data['id'] = $id ?: Uuid::randomHex();
        $data['languageId'] = $context->getContext()->getLanguageId();
        $data['salesChannelId'] = $context->getSalesChannel()->getId();
        $data['status'] = $this->getOptionSelection($context)[$data['option']];
        $data['hash'] = Uuid::randomHex();

        return $data;
    }

    private function getNewsletterRecipientId(string $email, SalesChannelContext $context): ?string
    {
        $criteria = new Criteria();
        $criteria->addFilter(
            
Home | Imprint | This part of the site doesn't use cookies.