public function afterAction($action, $result)
    {
        $params = [];
        if ($result instanceof \yii\web\Response || is_string($result)) {
            return parent::afterAction($action, $result);
        } elseif ($result instanceof Model) {
            $params['model'] = $result;
        } elseif ($result instanceof DataProviderInterface) {
            $params['dataProvider'] = $result;
        } else {
            $params = $result;
        }

        if (($response = $this->getHtmlResponse($action, $result, $params)) !== false) {
            return $response;
        }

        if (($response = $this->getPdfResponse($action, $result, $params)) !== false) {
            return $response;
        }

        if (($response = $this->getSerializedResponse($action, $result, $params)) !== false) {
            return $response;
        }

        // use a renderer stream for large data providers
        return $this->getLargeResponse($action, $result, $params);
    }