Cake\View\JsonView::render PHP Метод

render() публичный Метод

### Special parameters _serialize To convert a set of view variables into a JSON response. Its value can be a string for single variable name or array for multiple names. If true all view variables will be serialized. It unset normal view template will be rendered. _jsonp Enables JSONP support and wraps response in callback function provided in query string. - Setting it to true enables the default query string parameter "callback". - Setting it to a string value, uses the provided query string parameter for finding the JSONP callback name.
public render ( string | null $view = null, string | null $layout = null ) : string | null
$view string | null The view being rendered.
$layout string | null The layout being rendered.
Результат string | null The rendered view.
    public function render($view = null, $layout = null)
    {
        $return = parent::render($view, $layout);
        if (!empty($this->viewVars['_jsonp'])) {
            $jsonpParam = $this->viewVars['_jsonp'];
            if ($this->viewVars['_jsonp'] === true) {
                $jsonpParam = 'callback';
            }
            if (isset($this->request->query[$jsonpParam])) {
                $return = sprintf('%s(%s)', h($this->request->query[$jsonpParam]), $return);
                $this->response->type('js');
            }
        }
        return $return;
    }