src/Controller/Api/CaseV1P0Controller.php
/**
     * Generate a response for a collection of objects.
     */
Generate a response for a collection of objects.
Generate a response for a collection of objects .
protected function generateObjectCollectionResponse(Request $request, CaseApiInterface $obj): Response
    {
        $this->info('CASE API: Returned object', ['type' => get_class($obj), 'id' => $obj->getIdentifier()]);
        $response = $this->generateBaseResponse(new \DateTime());
        if ($response->isNotModified($request)) {
            return $response;
        }
        $collection = explode('/', $request->getPathInfo())[4];
        $serializationGroups = [
            'Default',
            preg_replace('/.*\\\\/', '', get_class($obj)),
        ];
        $serializationContext = $this->createSerializationContext($request, $serializationGroups);
        $result = $this->serializer->serialize(
            [$collection => [$obj]],
            $request->getRequestFormat('json'),
            $serializationContext
        );
        $response->setContent($result);
        return $response;
    }
protected function generateObjectCollectionResponse ( Request $ request , CaseApiInterface $ obj ) : Response { $ this -> info ( 'CASE API: Returned object' , [ 'type' => get_class ( $ obj ) , 'id' => $ obj -> getIdentifier ( ) ] ) ; $ response = $ this -> generateBaseResponse ( new \ DateTime ( ) ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ collection = explode ( '/' , $ request -> getPathInfo ( ) ) [ 4 ] ; $ serializationGroups = [ 'Default' , preg_replace ( '/.*\\\\/' , '' , get_class ( $ obj ) ) , ] ; $ serializationContext = $ this -> createSerializationContext ( $ request , $ serializationGroups ) ; $ result = $ this -> serializer -> serialize ( [ $ collection => [ $ obj ] ] , $ request -> getRequestFormat ( 'json' ) , $ serializationContext ) ; $ response -> setContent ( $ result ) ; return $ response ; }
Generate a response for a collection of objects.
Generate a response for a collection of objects .