@@ -43,7 +43,7 @@ class ProfilerController
43
43
* @param array $templates The templates
44
44
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
45
45
*/
46
- public function __construct (UrlGeneratorInterface $ generator , Profiler $ profiler , \Twig_Environment $ twig , array $ templates , $ toolbarPosition = 'normal ' )
46
+ public function __construct (UrlGeneratorInterface $ generator , Profiler $ profiler = null , \Twig_Environment $ twig , array $ templates , $ toolbarPosition = 'normal ' )
47
47
{
48
48
$ this ->generator = $ generator ;
49
49
$ this ->profiler = $ profiler ;
@@ -59,6 +59,10 @@ public function __construct(UrlGeneratorInterface $generator, Profiler $profiler
59
59
*/
60
60
public function homeAction ()
61
61
{
62
+ if (null === $ this ->profiler ) {
63
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
64
+ }
65
+
62
66
$ this ->profiler ->disable ();
63
67
64
68
return new RedirectResponse ($ this ->generator ->generate ('_profiler_search_results ' , array ('token ' => 'empty ' , 'limit ' => 10 )));
@@ -76,6 +80,10 @@ public function homeAction()
76
80
*/
77
81
public function panelAction (Request $ request , $ token )
78
82
{
83
+ if (null === $ this ->profiler ) {
84
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
85
+ }
86
+
79
87
$ this ->profiler ->disable ();
80
88
81
89
$ panel = $ request ->query ->get ('panel ' , 'request ' );
@@ -112,6 +120,10 @@ public function panelAction(Request $request, $token)
112
120
*/
113
121
public function exportAction ($ token )
114
122
{
123
+ if (null === $ this ->profiler ) {
124
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
125
+ }
126
+
115
127
$ this ->profiler ->disable ();
116
128
117
129
if (!$ profile = $ this ->profiler ->loadProfile ($ token )) {
@@ -131,6 +143,10 @@ public function exportAction($token)
131
143
*/
132
144
public function purgeAction ()
133
145
{
146
+ if (null === $ this ->profiler ) {
147
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
148
+ }
149
+
134
150
$ this ->profiler ->disable ();
135
151
$ this ->profiler ->purge ();
136
152
@@ -146,6 +162,10 @@ public function purgeAction()
146
162
*/
147
163
public function importAction (Request $ request )
148
164
{
165
+ if (null === $ this ->profiler ) {
166
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
167
+ }
168
+
149
169
$ this ->profiler ->disable ();
150
170
151
171
$ file = $ request ->files ->get ('file ' );
@@ -170,6 +190,10 @@ public function importAction(Request $request)
170
190
*/
171
191
public function infoAction ($ about )
172
192
{
193
+ if (null === $ this ->profiler ) {
194
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
195
+ }
196
+
173
197
$ this ->profiler ->disable ();
174
198
175
199
return new Response ($ this ->twig ->render ('@WebProfiler/Profiler/info.html.twig ' , array (
@@ -187,6 +211,10 @@ public function infoAction($about)
187
211
*/
188
212
public function toolbarAction (Request $ request , $ token )
189
213
{
214
+ if (null === $ this ->profiler ) {
215
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
216
+ }
217
+
190
218
$ session = $ request ->getSession ();
191
219
192
220
if (null !== $ session && $ session ->getFlashBag () instanceof AutoExpireFlashBag) {
@@ -234,6 +262,10 @@ public function toolbarAction(Request $request, $token)
234
262
*/
235
263
public function searchBarAction (Request $ request )
236
264
{
265
+ if (null === $ this ->profiler ) {
266
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
267
+ }
268
+
237
269
$ this ->profiler ->disable ();
238
270
239
271
if (null === $ session = $ request ->getSession ()) {
@@ -275,6 +307,10 @@ public function searchBarAction(Request $request)
275
307
*/
276
308
public function searchResultsAction (Request $ request , $ token )
277
309
{
310
+ if (null === $ this ->profiler ) {
311
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
312
+ }
313
+
278
314
$ this ->profiler ->disable ();
279
315
280
316
$ profile = $ this ->profiler ->loadProfile ($ token );
@@ -309,6 +345,10 @@ public function searchResultsAction(Request $request, $token)
309
345
*/
310
346
public function searchAction (Request $ request )
311
347
{
348
+ if (null === $ this ->profiler ) {
349
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
350
+ }
351
+
312
352
$ this ->profiler ->disable ();
313
353
314
354
$ ip = preg_replace ('/[^:\d\.]/ ' , '' , $ request ->query ->get ('ip ' ));
@@ -353,6 +393,10 @@ public function searchAction(Request $request)
353
393
*/
354
394
public function phpinfoAction ()
355
395
{
396
+ if (null === $ this ->profiler ) {
397
+ throw new NotFoundHttpException ('The profiler must be enabled. ' );
398
+ }
399
+
356
400
$ this ->profiler ->disable ();
357
401
358
402
ob_start ();
0 commit comments