Created
September 24, 2019 10:18
-
-
Save jaimeperez/d53874daa52bf42ac712aa368643f338 to your computer and use it in GitHub Desktop.
How to return different responses from a controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // if the response is XML: | |
| $response = new \Symfony\Component\HttpFoundation\Response(); | |
| $response->setContent($xml); | |
| return $response; | |
| // if the response is a twig template: | |
| $template = new \SimpleSAML\XHTML\Template('whatever.twig'); | |
| $template->data = ['foo' => 'bar']; | |
| return $template; | |
| // finally, if the response is an old PHP template: | |
| $template = new \SimpleSAML\XHTML\Template('whatever.tpl.php'); | |
| $template->data = ['foo' => 'bar']; | |
| return new \Symfony\Component\HttpFoundation\StreamedResponse([$template, 'show']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment