Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142<?php
final class AphrontJSONResponse extends AphrontResponse {
private $content; private $addJSONShield;
public function setContent($content) { $this->content = $content; return $this; }
public function setAddJSONShield($should_add) { $this->addJSONShield = $should_add; return $this; }
public function shouldAddJSONShield() { if ($this->addJSONShield === null) { return true; } return (bool)$this->addJSONShield; }
public function buildResponseString() { $response = $this->encodeJSONForHTTPResponse($this->content); if ($this->shouldAddJSONShield()) { $response = $this->addJSONShield($response); } return $response; }
public function getHeaders() { $headers = parent::getHeaders();
$headers[] = array('Content-Type', 'application/json');
return $headers; }
}