Path: blob/master/src/aphront/response/AphrontProxyResponse.php
12241 views
<?php12/**3* Base class for responses which augment other types of responses. For example,4* a response might be substantially an Ajax response, but add structure to the5* response content. It can do this by extending @{class:AphrontProxyResponse},6* instantiating an @{class:AphrontAjaxResponse} in @{method:buildProxy}, and7* then constructing a real @{class:AphrontAjaxResponse} in8* @{method:reduceProxyResponse}.9*/10abstract class AphrontProxyResponse11extends AphrontResponse12implements AphrontResponseProducerInterface {1314private $proxy;1516protected function getProxy() {17if (!$this->proxy) {18$this->proxy = $this->buildProxy();19}20return $this->proxy;21}2223public function setRequest($request) {24$this->getProxy()->setRequest($request);25return $this;26}2728public function getRequest() {29return $this->getProxy()->getRequest();30}3132public function getHeaders() {33return $this->getProxy()->getHeaders();34}3536public function setCacheDurationInSeconds($duration) {37$this->getProxy()->setCacheDurationInSeconds($duration);38return $this;39}4041public function setCanCDN($can_cdn) {42$this->getProxy()->setCanCDN($can_cdn);43return $this;44}4546public function setLastModified($epoch_timestamp) {47$this->getProxy()->setLastModified($epoch_timestamp);48return $this;49}5051public function setHTTPResponseCode($code) {52$this->getProxy()->setHTTPResponseCode($code);53return $this;54}5556public function getHTTPResponseCode() {57return $this->getProxy()->getHTTPResponseCode();58}5960public function setFrameable($frameable) {61$this->getProxy()->setFrameable($frameable);62return $this;63}6465public function getCacheHeaders() {66return $this->getProxy()->getCacheHeaders();67}6869abstract protected function buildProxy();70abstract public function reduceProxyResponse();7172final public function buildResponseString() {73throw new Exception(74pht(75'%s must implement %s.',76__CLASS__,77'reduceProxyResponse()'));78}798081/* -( AphrontResponseProducerInterface )----------------------------------- */828384public function produceAphrontResponse() {85return $this->reduceProxyResponse();86}8788}899091