@@ -762,12 +762,6 @@ headers and content that's sent back to the client::
762
762
$response = new Response('<style> ... </style>');
763
763
$response->headers->set('Content-Type', 'text/css');
764
764
765
- .. seealso ::
766
-
767
- Now that you know the basics you can continue your research on Symfony
768
- ``Request `` and ``Response `` object in the
769
- :ref: `HttpFoundation component documentation <component-http-foundation-request >`.
770
-
771
765
There are also special classes to make certain kinds of responses easier:
772
766
773
767
* For JSON, there is :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse `.
@@ -791,14 +785,17 @@ a ``JsonResponse()`` and encodes the given contents automatically::
791
785
public function indexAction()
792
786
{
793
787
// returns '{"username":"jane.doe"}' and sets the proper Content-Type header
794
- $data = array('username' => 'jane.doe');
795
- return $this->json($data);
788
+ return $this->json(array('username' => 'jane.doe'));
789
+
790
+ // the shortcut defines three optional arguments
791
+ // return $this->json($data, $status = 200, $headers = array(), $context = array());
796
792
}
797
793
798
- The only required argument is the data to be sent, but ``json() `` defines three
799
- more optional arguments::
794
+ .. seealso ::
800
795
801
- $this->json($data, $status = 200, $headers = array(), $context = array());
796
+ Now that you know the basics you can continue your research on Symfony
797
+ ``Request `` and ``Response `` object in the
798
+ :ref: `HttpFoundation component documentation <component-http-foundation-request >`.
802
799
803
800
Creating Static Pages
804
801
---------------------
0 commit comments