File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -395,17 +395,29 @@ use the ``render()`` helper::
395
395
namespace App\Controller;
396
396
397
397
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
398
+ use Symfony\Component\HttpFoundation\Response;
398
399
399
400
class ProductController extends AbstractController
400
401
{
401
402
public function index()
402
403
{
403
404
// ...
404
405
406
+ // the `render()` method returns a `Response` object with the
407
+ // contents created by the template
405
408
return $this->render('product/index.html.twig', [
406
409
'category' => '...',
407
410
'promotions' => ['...', '...'],
408
411
]);
412
+
413
+ // the `renderView()` method only returns the contents created by the
414
+ // template, so you can use those contents later in a `Response` object
415
+ $contents = $this->renderView('product/index.html.twig', [
416
+ 'category' => '...',
417
+ 'promotions' => ['...', '...'],
418
+ ]);
419
+
420
+ return new Response($contents);
409
421
}
410
422
}
411
423
You can’t perform that action at this time.
0 commit comments