@@ -83,30 +83,33 @@ The ``generateUrl()`` is the same method as the ``path()`` function used in the
83
83
templates. It takes the route name and an array of parameters as arguments and
84
84
returns the associated friendly URL.
85
85
86
- You can also forward internally the action to another one with the ``forward() ``
86
+ You can also internally forward the action to another using the ``forward() ``
87
87
method::
88
88
89
- return $this->forward('AcmeDemoBundle:Hello:fancy', array('name' => $name, 'color' => 'green'));
89
+ return $this->forward('AcmeDemoBundle:Hello:fancy', array(
90
+ 'name' => $name,
91
+ 'color' => 'green'
92
+ ));
90
93
91
94
Displaying Error Pages
92
95
----------------------
93
96
94
97
Errors will inevitably happen during the execution of every web application.
95
98
In the case of ``404 `` errors, Symfony includes a handy shortcut that you can
96
- use on your controllers::
99
+ use in your controllers::
97
100
98
101
throw $this->createNotFoundException();
99
102
100
103
For ``500 `` errors, just throw a regular PHP exception inside the controller and
101
- Symfony will transform it in a proper ``500 `` error page::
104
+ Symfony will transform it into a proper ``500 `` error page::
102
105
103
106
throw new \Exception('Something went wrong!');
104
107
105
108
Getting information from the Request
106
109
------------------------------------
107
110
108
- Symfony automatically injects the ``Request `` object when the controller defines
109
- a variable type hinted with `Symfony\Component\HttpFoundation\Request `::
111
+ Symfony automatically injects the ``Request `` object when the controller has an
112
+ argument that's type hinted with ` `Symfony\Component\HttpFoundation\Request` ::
110
113
111
114
use Symfony\Component\HttpFoundation\Request;
112
115
@@ -158,8 +161,8 @@ from any controller::
158
161
}
159
162
160
163
You can also store "flash messages" that will auto-delete after the next request.
161
- They are useful for instance when you need to set a success message before
162
- redirecting the user to another page (which will then show the message)::
164
+ They are useful when you need to set a success message before redirecting the
165
+ user to another page (which will then show the message)::
163
166
164
167
// store a message for the very next request (in a controller)
165
168
$session->getFlashBag()->add('notice', 'Congratulations, your action succeeded!');
0 commit comments