lib: Rename Request::getIsApiRequest() to ::isApiRequest()

There's no setter involved.

refs #9606
This commit is contained in:
Eric Lippmann 2015-08-20 16:02:25 +02:00
parent 62f0281a62
commit 870b73ae09
3 changed files with 21 additions and 21 deletions

View File

@ -78,7 +78,7 @@ class ErrorController extends ActionController
break; break;
} }
if ($this->getRequest()->getIsApiRequest()) { if ($this->getRequest()->isApiRequest()) {
// @TODO(el): Use ApiResponse class for unified response handling. // @TODO(el): Use ApiResponse class for unified response handling.
$this->getRequest()->sendJson(array( $this->getRequest()->sendJson(array(
'status' => 'error', 'status' => 'error',

View File

@ -990,7 +990,7 @@ class Form extends Zend_Form
if (! $this->tokenDisabled) { if (! $this->tokenDisabled) {
$request = $this->getRequest(); $request = $this->getRequest();
if (! $request->isXmlHttpRequest() if (! $request->isXmlHttpRequest()
&& ($this->getIsApiTarget() || $request->getIsApiRequest()) && ($this->getIsApiTarget() || $request->isApiRequest())
) { ) {
return $this; return $this;
} }
@ -1067,7 +1067,7 @@ class Form extends Zend_Form
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this)) && (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this))
|| ($this->onSuccess === null && false !== $this->onSuccess())) || ($this->onSuccess === null && false !== $this->onSuccess()))
) { ) {
if ($this->getIsApiTarget() || $this->getRequest()->getIsApiRequest()) { if ($this->getIsApiTarget() || $this->getRequest()->isApiRequest()) {
// API targets and API requests will never redirect but immediately respond w/ JSON-encoded // API targets and API requests will never redirect but immediately respond w/ JSON-encoded
// notifications // notifications
$messages = Notification::getInstance()->popMessages(); $messages = Notification::getInstance()->popMessages();

View File

@ -14,11 +14,11 @@ use Icinga\User;
class Request extends Zend_Controller_Request_Http class Request extends Zend_Controller_Request_Http
{ {
/** /**
* User if authenticated * Response
* *
* @var User|null * @var Response
*/ */
protected $user; protected $response;
/** /**
* Unique identifier * Unique identifier
@ -35,20 +35,24 @@ class Request extends Zend_Controller_Request_Http
protected $url; protected $url;
/** /**
* Response * User if authenticated
* *
* @var Response * @var User|null
*/ */
protected $response; protected $user;
/** /**
* Get whether the request seems to be an API request * Get the response
* *
* @return bool * @return Response
*/ */
public function getIsApiRequest() public function getResponse()
{ {
return $this->getHeader('Accept') === 'application/json'; if ($this->response === null) {
$this->response = Icinga::app()->getResponse();
}
return $this->response;
} }
/** /**
@ -88,17 +92,13 @@ class Request extends Zend_Controller_Request_Http
} }
/** /**
* Get the response * Get whether the request seems to be an API request
* *
* @return Response * @return bool
*/ */
public function getResponse() public function isApiRequest()
{ {
if ($this->response === null) { return $this->getHeader('Accept') === 'application/json';
$this->response = Icinga::app()->getResponse();
}
return $this->response;
} }
/** /**