/** * Should we return the error as JSON? * * @access protected * @return boolean */ protected function returnAsJson() { $acceptableContentTypes = $this->request->acceptableContentTypes(); return $this->request->isAjax() || isset($acceptableContentTypes[0]) && in_array($acceptableContentTypes[0], ['application/json', 'text/json']); }