remove callback from constructor and create method
This commit is contained in:
parent
601b87ca01
commit
4a43453db8
@ -27,24 +27,20 @@ class JsonResponse extends Response
|
||||
* @param mixed $data The response data
|
||||
* @param integer $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
* @param string $callback A JSONP callback name
|
||||
*/
|
||||
public function __construct($data = array(), $status = 200, $headers = array(), $callback = null)
|
||||
public function __construct($data = array(), $status = 200, $headers = array())
|
||||
{
|
||||
parent::__construct('', $status, $headers);
|
||||
|
||||
$this->setData($data);
|
||||
$this->setCallback($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param string $callback A JSONP callback name.
|
||||
*/
|
||||
static public function create($data = array(), $status = 200, $headers = array(), $callback = null)
|
||||
static public function create($data = array(), $status = 200, $headers = array())
|
||||
{
|
||||
return new static($data, $status, $headers, $callback);
|
||||
return new static($data, $status, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,14 +89,6 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function testJsonp()
|
||||
{
|
||||
$response = new JsonResponse(array('foo' => 'bar'), 200, array(), 'callback');
|
||||
|
||||
$this->assertEquals('callback({"foo":"bar"});', $response->getContent());
|
||||
$this->assertEquals('text/javascript', $response->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testSetCallback()
|
||||
{
|
||||
$response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback');
|
||||
|
Reference in New Issue
Block a user