src/EventListener/DeserializeListener.php
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        $method = $request->getMethod();

        if (
            'DELETE' === $method
            || $request->isMethodSafe(false)
            || !($attributes = RequestAttributesExtractor::extractAttributes($request))
            || !$attributes['receive']
            || (
                    '' === ($requestContent = $request->getContent())
                    && ('POST' === $method || 'PUT' === $method)
               )
        ) {
            return;
        }

        $context = $this->serializerContextBuilder->createFromRequest($request, false, $attributes);
        if (isset($context['input']) && \array_key_exists('class', $context['input']) && null === $context['input']['class']) {
            return;
        }

        // BC check to be removed in 3.0
        if (null !== $this->formatsProvider) {
            $this->formats = $this->formatsProvider->getFormatsFromAttributes($attributes);
        }
        $this->formatMatcher = new FormatMatcher($this->formats);
        $format = $this->getFormat($request);

        $data = $request->attributes->get('data');
        if (null !== $data) {
            $context[AbstractNormalizer::OBJECT_TO_POPULATE] = $data;
        }

        $request->attributes->set(
            'data',
            $this->serializer->deserialize(
                $requestContent, $context['resource_class'], $format, $context
            )
        );
    }
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        $method = $request->getMethod();

        if (
            'DELETE' === $method
            || $request->isMethodSafe(false)
            || !($attributes = RequestAttributesExtractor::extractAttributes($request))
            || !$attributes['receive']
            || (
                    '' === ($requestContent = $request->getContent())
                    && ('POST' === $method || 'PUT' === $method)
               )
        ) {
            return;
        }

        $context = $this->serializerContextBuilder->createFromRequest($request, false, $attributes);
        if (isset($context['input']) && \array_key_exists('class', $context['input']) && null === $context['input']['class']) {
            return;
        }

        // BC check to be removed in 3.0
        if (null !== $this->formatsProvider) {
            $this->formats = $this->formatsProvider->getFormatsFromAttributes($attributes);
        }
        $this->formatMatcher = new FormatMatcher($this->formats);
        $format = $this->getFormat($request);

        $data = $request->attributes->get('data');
        if (null !== $data) {
            $context[AbstractNormalizer::OBJECT_TO_POPULATE] = $data;
        }

        $request->attributes->set(
            'data',
            $this->serializer->deserialize(
                $requestContent, $context['resource_class'], $format, $context
            )
        );
    }
public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; $ method = $ request -> getMethod ( ) ; if ( 'DELETE' === $ method || $ request -> isMethodSafe ( false ) || ! ( $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) || ! $ attributes [ 'receive' ] || ( '' === ( $ requestContent = $ request -> getContent ( ) ) && ( 'POST' === $ method || 'PUT' === $ method ) ) ) { return ; } $ context = $ this -> serializerContextBuilder -> createFromRequest ( $ request , false , $ attributes ) ; if ( isset ( $ context [ 'input' ] ) && \ array_key_exists ( 'class' , $ context [ 'input' ] ) && null === $ context [ 'input' ] [ 'class' ] ) { return ; } // BC check to be removed in 3.0 if ( null !== $ this -> formatsProvider ) { $ this -> formats = $ this -> formatsProvider -> getFormatsFromAttributes ( $ attributes ) ; } $ this -> formatMatcher = new FormatMatcher ( $ this -> formats ) ; $ format = $ this -> getFormat ( $ request ) ; $ data = $ request -> attributes -> get ( 'data' ) ; if ( null !== $ data ) { $ context [ AbstractNormalizer :: OBJECT_TO_POPULATE ] = $ data ; } $ request -> attributes -> set ( 'data' , $ this -> serializer -> deserialize ( $ requestContent , $ context [ 'resource_class' ] , $ format , $ context ) ) ; }
Deserializes the data sent in the requested format.
Deserializes the data sent in the requested format .