Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/response/AphrontProxyResponse.php
<?php | <?php | ||||
/** | /** | ||||
* Base class for responses which augment other types of responses. For example, | * Base class for responses which augment other types of responses. For example, | ||||
* a response might be substantially an Ajax response, but add structure to the | * a response might be substantially an Ajax response, but add structure to the | ||||
* response content. It can do this by extending @{class:AphrontProxyResponse}, | * response content. It can do this by extending @{class:AphrontProxyResponse}, | ||||
* instantiating an @{class:AphrontAjaxResponse} in @{method:buildProxy}, and | * instantiating an @{class:AphrontAjaxResponse} in @{method:buildProxy}, and | ||||
* then constructing a real @{class:AphrontAjaxResponse} in | * then constructing a real @{class:AphrontAjaxResponse} in | ||||
* @{method:reduceProxyResponse}. | * @{method:reduceProxyResponse}. | ||||
*/ | */ | ||||
abstract class AphrontProxyResponse extends AphrontResponse { | abstract class AphrontProxyResponse | ||||
extends AphrontResponse | |||||
implements AphrontResponseProducerInterface { | |||||
private $proxy; | private $proxy; | ||||
protected function getProxy() { | protected function getProxy() { | ||||
if (!$this->proxy) { | if (!$this->proxy) { | ||||
$this->proxy = $this->buildProxy(); | $this->proxy = $this->buildProxy(); | ||||
} | } | ||||
return $this->proxy; | return $this->proxy; | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | abstract class AphrontProxyResponse | ||||
final public function buildResponseString() { | final public function buildResponseString() { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'%s must implement %s.', | '%s must implement %s.', | ||||
__CLASS__, | __CLASS__, | ||||
'reduceProxyResponse()')); | 'reduceProxyResponse()')); | ||||
} | } | ||||
/* -( AphrontResponseProducerInterface )----------------------------------- */ | |||||
public function produceAphrontResponse() { | |||||
return $this->reduceProxyResponse(); | |||||
} | |||||
} | } |