@@ -472,10 +472,13 @@ value to each variable.
472
472
object::
473
473
474
474
$httpKernel = $this->container->get('http_kernel');
475
- $response = $httpKernel->forward('AcmeHelloBundle:Hello:fancy', array(
476
- 'name' => $name,
477
- 'color' => 'green',
478
- ));
475
+ $response = $httpKernel->forward(
476
+ 'AcmeHelloBundle:Hello:fancy',
477
+ array(
478
+ 'name' => $name,
479
+ 'color' => 'green',
480
+ )
481
+ );
479
482
480
483
.. index ::
481
484
single: Controller; Rendering templates
@@ -490,14 +493,20 @@ that's responsible for generating the HTML (or other format) for the controller.
490
493
The ``renderView() `` method renders a template and returns its content. The
491
494
content from the template can be used to create a ``Response `` object::
492
495
493
- $content = $this->renderView('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
496
+ $content = $this->renderView(
497
+ 'AcmeHelloBundle:Hello:index.html.twig',
498
+ array('name' => $name)
499
+ );
494
500
495
501
return new Response($content);
496
502
497
503
This can even be done in just one step with the ``render() `` method, which
498
504
returns a ``Response `` object containing the content from the template::
499
505
500
- return $this->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
506
+ return $this->render(
507
+ 'AcmeHelloBundle:Hello:index.html.twig',
508
+ array('name' => $name)
509
+ );
501
510
502
511
In both cases, the ``Resources/views/Hello/index.html.twig `` template inside
503
512
the ``AcmeHelloBundle `` will be rendered.
@@ -517,15 +526,21 @@ The Symfony templating engine is explained in great detail in the
517
526
service. The ``templating `` service can also be used directly::
518
527
519
528
$templating = $this->get('templating');
520
- $content = $templating->render('AcmeHelloBundle:Hello:index.html.twig', array('name' => $name));
529
+ $content = $templating->render(
530
+ 'AcmeHelloBundle:Hello:index.html.twig',
531
+ array('name' => $name)
532
+ );
521
533
522
534
.. note ::
523
535
524
536
It is possible to render templates in deeper subdirectories as well, however
525
537
be careful to avoid the pitfall of making your directory structure unduly
526
538
elaborate::
527
539
528
- $templating->render('AcmeHelloBundle:Hello/Greetings:index.html.twig', array('name' => $name));
540
+ $templating->render(
541
+ 'AcmeHelloBundle:Hello/Greetings:index.html.twig',
542
+ array('name' => $name)
543
+ );
529
544
// index.html.twig found in Resources/views/Hello/Greetings is rendered.
530
545
531
546
.. index ::
@@ -642,7 +657,10 @@ For example, imagine you're processing a form submit::
642
657
if ($form->isValid()) {
643
658
// do some sort of processing
644
659
645
- $this->get('session')->setFlash('notice', 'Your changes were saved!');
660
+ $this->get('session')->setFlash(
661
+ 'notice',
662
+ 'Your changes were saved!'
663
+ );
646
664
647
665
return $this->redirect($this->generateUrl(...));
648
666
}
0 commit comments