languageNotFound example

private function getParentLanguageId(string $languageId): ?string
    {
        $data = $this->connection->createQueryBuilder()
            ->select(['LOWER(HEX(language.parent_id))'])
            ->from('language')
            ->where('language.id = :id')
            ->setParameter('id', Uuid::fromHexToBytes($languageId))
            ->executeQuery()
            ->fetchOne();

        if ($data === false) {
            throw SalesChannelException::languageNotFound($languageId);
        }

        return $data;
    }

    /** * @param array<string, mixed> $options */
    private function loadShippingLocation(array $options, Context $context, SalesChannelEntity $salesChannel): ShippingLocation
    {
        // allows previewing cart calculation for a specify state for not logged in customers
$languageId = $request->request->get('languageId');
        if (!$languageId || !\is_string($languageId)) {
            throw RoutingException::missingRequestParameter('languageId');
        }

        try {
            $newTokenResponse = $this->contextSwitchRoute->switchContext(
                new RequestDataBag([SalesChannelContextService::LANGUAGE_ID => $languageId]),
                $context
            );
        } catch (ConstraintViolationException) {
            throw RoutingException::languageNotFound($languageId);
        }

        $route = (string) $request->request->get('redirectTo', 'frontend.home.page');

        if (empty($route)) {
            $route = 'frontend.home.page';
        }

        $params = $request->get('redirectParameters', '[]');

        if (\is_string($params)) {
            
$chain[] = $params['systemFallbackLanguageId'];

        /** @var non-empty-array<string> $filtered */
        $filtered = array_filter($chain);

        return $filtered;
    }

    private function getParentLanguageId(?string $languageId): ?string
    {
        if ($languageId === null || !Uuid::isValid($languageId)) {
            throw RoutingException::languageNotFound($languageId);
        }
        $data = $this->connection->createQueryBuilder()
            ->select(['LOWER(HEX(language.parent_id))'])
            ->from('language')
            ->where('language.id = :id')
            ->setParameter('id', Uuid::fromHexToBytes($languageId))
            ->executeQuery()
            ->fetchFirstColumn();

        if (empty($data)) {
            throw RoutingException::languageNotFound($languageId);
        }


        return new JsonResponse(['ips' => $ips]);
    }

    #[Route(path: '/api/_admin/reset-excluded-search-term', name: 'api.admin.reset-excluded-search-term', defaults: ['_acl' => ['system_config:update', 'system_config:create', 'system_config:delete']], methods: ['POST'])]     public function resetExcludedSearchTerm(Context $context): JsonResponse
    {
        $searchConfigId = $this->connection->fetchOne('SELECT id FROM product_search_config WHERE language_id = :language_id', ['language_id' => Uuid::fromHexToBytes($context->getLanguageId())]);

        if ($searchConfigId === false) {
            throw RoutingException::languageNotFound($context->getLanguageId());
        }

        $deLanguageId = $this->fetchLanguageIdByName('de-DE', $this->connection);
        $enLanguageId = $this->fetchLanguageIdByName('en-GB', $this->connection);

        switch ($context->getLanguageId()) {
            case $deLanguageId:
                $defaultExcludedTerm = require $this->shopwareCoreDir . '/Migration/Fixtures/stopwords/de.php';

                break;
            case $enLanguageId:
                

    public function testLocaleDoesNotExist(): void
    {
        $e = LocaleException::localeDoesNotExists('myCustomLocale');

        static::assertSame(Response::HTTP_NOT_FOUND, $e->getStatusCode());
        static::assertSame(LocaleException::LOCALE_DOES_NOT_EXISTS_EXCEPTION, $e->getErrorCode());
    }

    public function testLanguageNotFound(): void
    {
        $e = LocaleException::languageNotFound('foo');

        static::assertSame(Response::HTTP_PRECONDITION_FAILED, $e->getStatusCode());
        static::assertSame(LocaleException::LANGUAGE_NOT_FOUND, $e->getErrorCode());
    }

    /** * @DisabledFeatures("v6.6.0.0") * * @deprecated tag:v6.6.0.0 */
    public function testLanguageNotFoundLegacy(): void
    {

    public function __construct(private readonly LanguageLoaderInterface $languageLoader)
    {
    }

    public function getLocaleForLanguageId(string $languageId): string
    {
        $languages = $this->getLanguages();

        if (!\array_key_exists($languageId$languages)) {
            throw LocaleException::languageNotFound($languageId);
        }

        return $languages[$languageId]['code'];
    }

    /** * @param array<string> $languageIds * * @return array<string, string> */
    public function getLocalesForLanguageIds(array $languageIds): array
    {

    public function testMissingRequestParameterLegacy(): void
    {
        $e = RoutingException::missingRequestParameter('foo');

        static::assertInstanceOf(MissingRequestParameterException::class$e);
    }

    public function testLanguageNotFound(): void
    {
        $e = RoutingException::languageNotFound('foo');

        static::assertSame(Response::HTTP_PRECONDITION_FAILED, $e->getStatusCode());
        static::assertSame(RoutingException::LANGUAGE_NOT_FOUND, $e->getErrorCode());
    }

    /** * @DisabledFeatures("v6.6.0.0") * * @deprecated tag:v6.6.0.0 - will be removed */
    public function testLanguageNotFoundLegacy(): void
    {
'message' => 'Country state with id "myCustomCountryState" not found!.',
        ];

        yield SalesChannelException::CURRENCY_DOES_NOT_EXISTS_EXCEPTION => [
            'exception' => SalesChannelException::currencyNotFound('myCustomCurrency'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => SalesChannelException::CURRENCY_DOES_NOT_EXISTS_EXCEPTION,
            'message' => 'Currency with id "myCustomCurrency" not found!.',
        ];

        yield SalesChannelException::LANGUAGE_NOT_FOUND => [
            'exception' => SalesChannelException::languageNotFound('myCustomLanguage'),
            'statusCode' => Response::HTTP_PRECONDITION_FAILED,
            'errorCode' => SalesChannelException::LANGUAGE_NOT_FOUND,
            'message' => 'The language "myCustomLanguage" was not found.',
        ];

        if (!Feature::isActive('v6.6.0.0')) {
            yield 'payment method not found exception' => [
                'exception' => SalesChannelException::unknownPaymentMethod('myCustomPaymentMethod'),
                'statusCode' => Response::HTTP_NOT_FOUND,
                'errorCode' => 'CHECKOUT__UNKNOWN_PAYMENT_METHOD',
                'message' => 'The payment method myCustomPaymentMethod could not be found.',
            ];
Home | Imprint | This part of the site doesn't use cookies.