private static function getViewPostfix($responseType) { $availableViewsMap = array('text/xml' => '.xml.phtml', 'application/json' => '.json.phtml', 'text/json' => '.json.phtml'); $viewForType = Arrays::getValue($availableViewsMap, $responseType, false); if ($viewForType) { return $viewForType; } return Uri::isAjax() ? '.ajax.phtml' : '.phtml'; }
/** * @test */ public function shouldReturnTrueWhenAjaxRequest() { //given $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; //when $isAjax = Uri::isAjax(); //then $this->assertTrue($isAjax); }
public function isAjax() { return Uri::isAjax(); }
private function needPrettyHandler() { $isHtmlResponse = ResponseTypeResolve::resolve() == "text/html"; return $isHtmlResponse && !Uri::isAjax(); }