Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e0785f

Browse filesBrowse files
error56fabpot
authored andcommitted
[Profiler] Update ProfilerController.php
1 parent de3c742 commit 6e0785f
Copy full SHA for 6e0785f

File tree

Expand file treeCollapse file tree

1 file changed

+15
-30
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-30
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
+15-30Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ public function __construct(UrlGeneratorInterface $generator, Profiler $profiler
5454
*/
5555
public function homeAction()
5656
{
57-
if (null === $this->profiler) {
58-
throw new NotFoundHttpException('The profiler must be enabled.');
59-
}
60-
61-
$this->profiler->disable();
57+
$this->denyAccessIfProfilerDisabled();
6258

6359
return new RedirectResponse($this->generator->generate('_profiler_search_results', ['token' => 'empty', 'limit' => 10]), 302, ['Content-Type' => 'text/html']);
6460
}
@@ -75,11 +71,7 @@ public function homeAction()
7571
*/
7672
public function panelAction(Request $request, $token)
7773
{
78-
if (null === $this->profiler) {
79-
throw new NotFoundHttpException('The profiler must be enabled.');
80-
}
81-
82-
$this->profiler->disable();
74+
$this->denyAccessIfProfilerDisabled();
8375

8476
if (null !== $this->cspHandler) {
8577
$this->cspHandler->disableCsp();
@@ -170,11 +162,7 @@ public function toolbarAction(Request $request, $token)
170162
*/
171163
public function searchBarAction(Request $request)
172164
{
173-
if (null === $this->profiler) {
174-
throw new NotFoundHttpException('The profiler must be enabled.');
175-
}
176-
177-
$this->profiler->disable();
165+
$this->denyAccessIfProfilerDisabled();
178166

179167
if (null !== $this->cspHandler) {
180168
$this->cspHandler->disableCsp();
@@ -231,11 +219,7 @@ public function searchBarAction(Request $request)
231219
*/
232220
public function searchResultsAction(Request $request, $token)
233221
{
234-
if (null === $this->profiler) {
235-
throw new NotFoundHttpException('The profiler must be enabled.');
236-
}
237-
238-
$this->profiler->disable();
222+
$this->denyAccessIfProfilerDisabled();
239223

240224
if (null !== $this->cspHandler) {
241225
$this->cspHandler->disableCsp();
@@ -276,11 +260,7 @@ public function searchResultsAction(Request $request, $token)
276260
*/
277261
public function searchAction(Request $request)
278262
{
279-
if (null === $this->profiler) {
280-
throw new NotFoundHttpException('The profiler must be enabled.');
281-
}
282-
283-
$this->profiler->disable();
263+
$this->denyAccessIfProfilerDisabled();
284264

285265
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
286266
$method = $request->query->get('method');
@@ -331,11 +311,7 @@ public function searchAction(Request $request)
331311
*/
332312
public function phpinfoAction()
333313
{
334-
if (null === $this->profiler) {
335-
throw new NotFoundHttpException('The profiler must be enabled.');
336-
}
337-
338-
$this->profiler->disable();
314+
$this->denyAccessIfProfilerDisabled();
339315

340316
if (null !== $this->cspHandler) {
341317
$this->cspHandler->disableCsp();
@@ -394,6 +370,15 @@ protected function getTemplateManager()
394370

395371
return $this->templateManager;
396372
}
373+
374+
private function denyAccessIfProfilerDisabled()
375+
{
376+
if (null === $this->profiler) {
377+
throw new NotFoundHttpException('The profiler must be enabled.');
378+
}
379+
380+
$this->profiler->disable();
381+
}
397382

398383
private function renderWithCspNonces(Request $request, $template, $variables, $code = 200, $headers = ['Content-Type' => 'text/html'])
399384
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.