protected function transformDataProvider(DataProviderInterface $dataProvider)
    {
        if (Craft::$app->getRequest()->getIsHead()) {
            return null;
        } else {
            if (!$transformer = $this->dataTransformer()) {
                return $dataProvider;
            }

            // The transformed data
            $models = Factory::collection(
                $this->resolveTransformer($transformer),
                $dataProvider->getModels(),
                $this->getTransformConfig()
            );

            if ($this->collectionEnvelope === null) {
                return $models;
            } else {
                return [
                    $this->collectionEnvelope => $models,
                ];
            }
        }
    }