12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Symfony\Component\HttpFoundation;
- class JsonResponse extends Response
- {
-
- public function __construct($data = array(), $status = 200, $headers = array())
- {
-
- if (is_array($data) && 0 === count($data)) {
- $data = new \ArrayObject();
- }
- parent::__construct(
- json_encode($data),
- $status,
- array_merge(array('Content-Type' => 'application/json'), $headers)
- );
- }
-
- static public function create($data = array(), $status = 200, $headers = array())
- {
- return new static($data, $status, $headers);
- }
- }
|