public function fetchCollection(
        EntityRequestInterface $entityRequest,
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next,
        $nameOfParameterToAdd = null
    ): ResponseInterface {

        $pks = [];
        if ($request->getMethod() === 'GET') {
            # GET : Try to find PKs in query
            $params = $request->getQueryParams();
            if (array_key_exists('id', $params)) {
                $pks = $params['id'];
            }
        } else {
            # POST/PATCH : Try to find PKs in body
            if (is_array($request->getParsedBody())) {
                $finder = new PksFinder(['id']);
                $pks    = $finder->find($request->getParsedBody());
            }
        }

        # Next, we create the query (ModelCriteria), based on Action class (which can alter the query)
        $query = $this->getQueryFromActiveRecordRequest($entityRequest);

        if (empty($pks)) {
            $handler = $entityRequest->getContainer()
                ->getEntityRequestErrorHandler();

            return $handler->primaryKeyNotFound($entityRequest, $request,
                $response);
        }

        # Then, fetch object
        $col = $query->findPks($pks);

        if ($col === null) {
            $handler = $entityRequest->getContainer()
                ->getEntityRequestErrorHandler();

            return $handler->entityNotFound($entityRequest, $request,
                $response);
        }

        # Finally, build name of parameter to inject in action method, will be used later
        if ($nameOfParameterToAdd === null) {
            $nameOfParameterToAdd
                = $entityRequest->getNameOfParameterToAdd(true);
        }
        $request = $request->withAttribute($nameOfParameterToAdd, $col);

        return $next($request, $response);
    }