src/EventListener/ReadListener.php
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (
            !($attributes = RequestAttributesExtractor::extractAttributes($request))
            || !$attributes['receive']
        ) {
            return;
        }

        if (null === $filters = $request->attributes->get('_api_filters')) {
            $queryString = RequestParser::getQueryString($request);
            $filters = $queryString ? RequestParser::parseRequestParams($queryString) : null;
        }

        $context = null === $filters ? [] : ['filters' => $filters];
        if ($this->serializerContextBuilder) {
            // Builtin data providers are able to use the serialization context to automatically add join clauses
            $context += $normalizationContext = $this->serializerContextBuilder->createFromRequest($request, true, $attributes);
            $request->attributes->set('_api_normalization_context', $normalizationContext);
        }

        if (isset($attributes['collection_operation_name'])) {
            $request->attributes->set('data', $request->isMethod('POST') ? null : $this->getCollectionData($attributes, $context));

            return;
        }

        $data = [];

        if ($this->identifierConverter) {
            $context[IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER] = true;
        }

        try {
            $identifiers = $this->extractIdentifiers($request->attributes->all(), $attributes);

            if (isset($attributes['item_operation_name'])) {
                $data = $this->getItemData($identifiers, $attributes, $context);
            } elseif (isset($attributes['subresource_operation_name'])) {
                // Legacy
                if (null === $this->subresourceDataProvider) {
                    throw new RuntimeException('No subresource data provider.');
                }

                $data = $this->getSubresourceData($identifiers, $attributes, $context);
            }
        } catch (InvalidIdentifierException $e) {
            throw new NotFoundHttpException('Not found, because of an invalid identifier configuration', $e);
        }

        if (null === $data) {
            throw new NotFoundHttpException('Not Found');
        }

        $request->attributes->set('data', $data);
    }
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (
            !($attributes = RequestAttributesExtractor::extractAttributes($request))
            || !$attributes['receive']
        ) {
            return;
        }

        if (null === $filters = $request->attributes->get('_api_filters')) {
            $queryString = RequestParser::getQueryString($request);
            $filters = $queryString ? RequestParser::parseRequestParams($queryString) : null;
        }

        $context = null === $filters ? [] : ['filters' => $filters];
        if ($this->serializerContextBuilder) {
            // Builtin data providers are able to use the serialization context to automatically add join clauses
            $context += $normalizationContext = $this->serializerContextBuilder->createFromRequest($request, true, $attributes);
            $request->attributes->set('_api_normalization_context', $normalizationContext);
        }

        if (isset($attributes['collection_operation_name'])) {
            $request->attributes->set('data', $request->isMethod('POST') ? null : $this->getCollectionData($attributes, $context));

            return;
        }

        $data = [];

        if ($this->identifierConverter) {
            $context[IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER] = true;
        }

        try {
            $identifiers = $this->extractIdentifiers($request->attributes->all(), $attributes);

            if (isset($attributes['item_operation_name'])) {
                $data = $this->getItemData($identifiers, $attributes, $context);
            } elseif (isset($attributes['subresource_operation_name'])) {
                // Legacy
                if (null === $this->subresourceDataProvider) {
                    throw new RuntimeException('No subresource data provider.');
                }

                $data = $this->getSubresourceData($identifiers, $attributes, $context);
            }
        } catch (InvalidIdentifierException $e) {
            throw new NotFoundHttpException('Not found, because of an invalid identifier configuration', $e);
        }

        if (null === $data) {
            throw new NotFoundHttpException('Not Found');
        }

        $request->attributes->set('data', $data);
    }
public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; if ( ! ( $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) || ! $ attributes [ 'receive' ] ) { return ; } if ( null === $ filters = $ request -> attributes -> get ( '_api_filters' ) ) { $ queryString = RequestParser :: getQueryString ( $ request ) ; $ filters = $ queryString ? RequestParser :: parseRequestParams ( $ queryString ) : null ; } $ context = null === $ filters ? [ ] : [ 'filters' => $ filters ] ; if ( $ this -> serializerContextBuilder ) { // Builtin data providers are able to use the serialization context to automatically add join clauses $ context += $ normalizationContext = $ this -> serializerContextBuilder -> createFromRequest ( $ request , true , $ attributes ) ; $ request -> attributes -> set ( '_api_normalization_context' , $ normalizationContext ) ; } if ( isset ( $ attributes [ 'collection_operation_name' ] ) ) { $ request -> attributes -> set ( 'data' , $ request -> isMethod ( 'POST' ) ? null : $ this -> getCollectionData ( $ attributes , $ context ) ) ; return ; } $ data = [ ] ; if ( $ this -> identifierConverter ) { $ context [ IdentifierConverterInterface :: HAS_IDENTIFIER_CONVERTER ] = true ; } try { $ identifiers = $ this -> extractIdentifiers ( $ request -> attributes -> all ( ) , $ attributes ) ; if ( isset ( $ attributes [ 'item_operation_name' ] ) ) { $ data = $ this -> getItemData ( $ identifiers , $ attributes , $ context ) ; } elseif ( isset ( $ attributes [ 'subresource_operation_name' ] ) ) { // Legacy if ( null === $ this -> subresourceDataProvider ) { throw new RuntimeException ( 'No subresource data provider.' ) ; } $ data = $ this -> getSubresourceData ( $ identifiers , $ attributes , $ context ) ; } } catch ( InvalidIdentifierException $ e ) { throw new NotFoundHttpException ( 'Not found, because of an invalid identifier configuration' , $ e ) ; } if ( null === $ data ) { throw new NotFoundHttpException ( 'Not Found' ) ; } $ request -> attributes -> set ( 'data' , $ data ) ; }
Calls the data provider and sets the data attribute.

@throws NotFoundHttpException
Calls the data provider and sets the data attribute .