providedLanguageNotAvailable example


    private function buildLanguageChain(array $sessionOptions, string $defaultLanguageId, array $availableLanguageIds): array
    {
        $current = $sessionOptions[SalesChannelContextService::LANGUAGE_ID] ?? $defaultLanguageId;

        if (!\is_string($current) || !Uuid::isValid($current)) {
            throw SalesChannelException::invalidLanguageId();
        }

        // check provided language is part of the available languages         if (!\in_array($current$availableLanguageIds, true)) {
            throw SalesChannelException::providedLanguageNotAvailable($current$availableLanguageIds);
        }

        if ($current === Defaults::LANGUAGE_SYSTEM) {
            return [Defaults::LANGUAGE_SYSTEM];
        }

        // provided language can be a child language         return array_filter([$current$this->getParentLanguageId($current), Defaults::LANGUAGE_SYSTEM]);
    }

    /** * @return CashRoundingConfig[] */
static::assertEquals($statusCode$exception->getStatusCode());
        static::assertEquals($errorCode$exception->getErrorCode());
        static::assertEquals($message$exception->getMessage());
    }

    /** * @return array<string, array{exception: ShopwareHttpException|SalesChannelException, statusCode: int, errorCode: string, message: string}> */
    public static function exceptionDataProvider(): iterable
    {
        yield SalesChannelException::SALES_CHANNEL_LANGUAGE_NOT_AVAILABLE_EXCEPTION => [
            'exception' => SalesChannelException::providedLanguageNotAvailable('myCustomScn', ['scn1', 'scn2']),
            'statusCode' => Response::HTTP_PRECONDITION_FAILED,
            'errorCode' => SalesChannelException::SALES_CHANNEL_LANGUAGE_NOT_AVAILABLE_EXCEPTION,
            'message' => 'Provided language "myCustomScn" is not in list of available languages: scn1, scn2',
        ];

        yield SalesChannelException::SALES_CHANNEL_DOES_NOT_EXISTS_EXCEPTION => [
            'exception' => SalesChannelException::salesChannelNotFound('myCustomScn'),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => SalesChannelException::SALES_CHANNEL_DOES_NOT_EXISTS_EXCEPTION,
            'message' => 'Sales channel with id "myCustomScn" not found or not valid!.',
        ];

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