invalidLanguageId example


        if ($this->currentWriteLanguageId !== null) {
            return $this->currentWriteLanguageId;
        }

        return $this->context->getContext()->getLanguageId();
    }

    public function setCurrentWriteLanguageId(string $languageId): void
    {
        if (!Uuid::isValid($languageId)) {
            throw DataAbstractionLayerException::invalidLanguageId($languageId);
        }

        $this->currentWriteLanguageId = $languageId;
    }

    public function getPrimaryKeyBag(): PrimaryKeyBag
    {
        return $this->primaryKeyBag;
    }

    public function setPrimaryKeyBag(PrimaryKeyBag $primaryKeyBag): void
    {
/** * @param array<string, mixed> $sessionOptions * @param array<string> $availableLanguageIds * * @return non-empty-array<string> */
    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];
        }

        

        $e = DataAbstractionLayerException::invalidApiCriteriaIds(
            DataAbstractionLayerException::invalidCriteriaIds(['foo'], 'bar')
        );

        static::assertSame(Response::HTTP_BAD_REQUEST, $e->getStatusCode());
        static::assertSame(DataAbstractionLayerException::INVALID_API_CRITERIA_IDS, $e->getErrorCode());
    }

    public function testInvalidLanguageId(): void
    {
        $e = DataAbstractionLayerException::invalidLanguageId('foo');

        static::assertSame(Response::HTTP_BAD_REQUEST, $e->getStatusCode());
        static::assertSame(DataAbstractionLayerException::INVALID_LANGUAGE_ID, $e->getErrorCode());
    }

    /** * @DisabledFeatures("v6.6.0.0") * * @deprecated tag:v6.6.0.0 - will be removed */
    public function testInvalidLanguageIdLegacy(): void
    {
'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!.',
        ];

        yield SalesChannelException::LANGUAGE_INVALID_EXCEPTION => [
            'exception' => SalesChannelException::invalidLanguageId(),
            'statusCode' => Response::HTTP_PRECONDITION_FAILED,
            'errorCode' => SalesChannelException::LANGUAGE_INVALID_EXCEPTION,
            'message' => 'Provided languageId is not a valid uuid',
        ];

        yield SalesChannelException::NO_CONTEXT_DATA_EXCEPTION => [
            'exception' => SalesChannelException::noContextData('myCustomScn'),
            'statusCode' => Response::HTTP_PRECONDITION_FAILED,
            'errorCode' => SalesChannelException::NO_CONTEXT_DATA_EXCEPTION,
            'message' => 'No context data found for SalesChannel "myCustomScn"',
        ];

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