bundles/BlockManagerBundle/EventListener/RequestBodyListener.php
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();

        if (!$event->isMasterRequest()) {
            return;
        }

        if ($request->attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
            return;
        }

        if (!$this->isDecodeable($request)) {
            return;
        }

        try {
            $data = $this->decoder->decode((string) $request->getContent(), 'json');
        } catch (UnexpectedValueException $e) {
            throw new BadRequestHttpException('Request body has an invalid format', $e);
        }

        if (!is_array($data)) {
            throw new BadRequestHttpException('Request body has an invalid format');
        }

        $request->attributes->set('data', new ParameterBag($data));
    }
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();

        if (!$event->isMasterRequest()) {
            return;
        }

        if ($request->attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
            return;
        }

        if (!$this->isDecodeable($request)) {
            return;
        }

        try {
            $data = $this->decoder->decode((string) $request->getContent(), 'json');
        } catch (UnexpectedValueException $e) {
            throw new BadRequestHttpException('Request body has an invalid format', $e);
        }

        if (!is_array($data)) {
            throw new BadRequestHttpException('Request body has an invalid format');
        }

        $request->attributes->set('data', new ParameterBag($data));
    }
public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; if ( ! $ event -> isMasterRequest ( ) ) { return ; } if ( $ request -> attributes -> get ( SetIsApiRequestListener :: API_FLAG_NAME ) !== true ) { return ; } if ( ! $ this -> isDecodeable ( $ request ) ) { return ; } try { $ data = $ this -> decoder -> decode ( ( string ) $ request -> getContent ( ) , 'json' ) ; } catch ( UnexpectedValueException $ e ) { throw new BadRequestHttpException ( 'Request body has an invalid format' , $ e ) ; } if ( ! is_array ( $ data ) ) { throw new BadRequestHttpException ( 'Request body has an invalid format' ) ; } $ request -> attributes -> set ( 'data' , new ParameterBag ( $ data ) ) ; }
Decodes the request data into request parameter bag.
Decodes the request data into request parameter bag .