[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class AphrontAjaxResponse extends AphrontResponse { 4 5 private $content; 6 private $error; 7 private $disableConsole; 8 9 public function setContent($content) { 10 $this->content = $content; 11 return $this; 12 } 13 14 public function setError($error) { 15 $this->error = $error; 16 return $this; 17 } 18 19 public function setDisableConsole($disable) { 20 $this->disableConsole = $disable; 21 return $this; 22 } 23 24 private function getConsole() { 25 if ($this->disableConsole) { 26 $console = null; 27 } else { 28 $request = $this->getRequest(); 29 $console = $request->getApplicationConfiguration()->getConsole(); 30 } 31 return $console; 32 } 33 34 public function buildResponseString() { 35 $console = $this->getConsole(); 36 if ($console) { 37 // NOTE: We're stripping query parameters here both for readability and 38 // to mitigate BREACH and similar attacks. The parameters are available 39 // in the "Request" tab, so this should not impact usability. See T3684. 40 $uri = $this->getRequest()->getRequestURI(); 41 $uri = new PhutilURI($uri); 42 $uri->setQueryParams(array()); 43 44 Javelin::initBehavior( 45 'dark-console', 46 array( 47 'uri' => (string)$uri, 48 'key' => $console->getKey($this->getRequest()), 49 'color' => $console->getColor(), 50 )); 51 } 52 53 // Flatten the response first, so we initialize any behaviors and metadata 54 // we need to. 55 $content = array( 56 'payload' => $this->content, 57 ); 58 $this->encodeJSONForHTTPResponse($content); 59 60 $response = CelerityAPI::getStaticResourceResponse(); 61 $object = $response->buildAjaxResponse( 62 $content['payload'], 63 $this->error); 64 65 $response_json = $this->encodeJSONForHTTPResponse($object); 66 return $this->addJSONShield($response_json); 67 } 68 69 public function getHeaders() { 70 $headers = array( 71 array('Content-Type', 'text/plain; charset=UTF-8'), 72 ); 73 $headers = array_merge(parent::getHeaders(), $headers); 74 return $headers; 75 } 76 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |