Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UnwrappingDenormalizerContextBuilder.php

function UnwrappingDenormalizerContextBuilder::withUnwrapPath

Configures the path of wrapped data during denormalization.

Eg: [foo].bar[bar]

Throws

InvalidArgumentException

See also

https://symfony.com/doc/current/components/property_access.html

File

vendor/symfony/serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php, line 39

Class

UnwrappingDenormalizerContextBuilder
A helper providing autocompletion for available UnwrappingDenormalizer options.

Namespace

Symfony\Component\Serializer\Context\Normalizer

Code

public function withUnwrapPath(?string $unwrapPath) : static {
    if (null === $unwrapPath) {
        return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, null);
    }
    try {
        new PropertyPath($unwrapPath);
    } catch (InvalidPropertyPathException $e) {
        throw new InvalidArgumentException(\sprintf('The "%s" property path is not valid.', $unwrapPath), previous: $e);
    }
    return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, $unwrapPath);
}
RSS feed
Powered by Drupal