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 abfa3ee

Browse filesBrowse files
committed
minor #25636 Backport Flex-specific error messages in controller shortcuts to 3.4 (weaverryan)
This PR was merged into the 3.4 branch. Discussion ---------- Backport Flex-specific error messages in controller shortcuts to 3.4 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25133 (comment) | License | MIT | Doc PR | n/a Commits ------- 419e934 Proposing Flex-specific error messages in the controller shortcuts
2 parents 682bf5b + 419e934 commit abfa3ee
Copy full SHA for abfa3ee

File tree

1 file changed

+9
-9
lines changed
Filter options

1 file changed

+9
-9
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protected function file($file, $fileName = null, $disposition = ResponseHeaderBa
194194
protected function addFlash($type, $message)
195195
{
196196
if (!$this->container->has('session')) {
197-
throw new \LogicException('You can not use the addFlash method if sessions are disabled.');
197+
throw new \LogicException('You can not use the addFlash method if sessions are disabled. Enable them in "config/packages/framework.yaml".');
198198
}
199199

200200
$this->container->get('session')->getFlashBag()->add($type, $message);
@@ -215,7 +215,7 @@ protected function addFlash($type, $message)
215215
protected function isGranted($attributes, $subject = null)
216216
{
217217
if (!$this->container->has('security.authorization_checker')) {
218-
throw new \LogicException('The SecurityBundle is not registered in your application.');
218+
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require security".');
219219
}
220220

221221
return $this->container->get('security.authorization_checker')->isGranted($attributes, $subject);
@@ -261,7 +261,7 @@ protected function renderView($view, array $parameters = array())
261261
}
262262

263263
if (!$this->container->has('twig')) {
264-
throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available.');
264+
throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available. Try running "composer require twig".');
265265
}
266266

267267
return $this->container->get('twig')->render($view, $parameters);
@@ -285,7 +285,7 @@ protected function render($view, array $parameters = array(), Response $response
285285
} elseif ($this->container->has('twig')) {
286286
$content = $this->container->get('twig')->render($view, $parameters);
287287
} else {
288-
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.');
288+
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require twig".');
289289
}
290290

291291
if (null === $response) {
@@ -323,7 +323,7 @@ protected function stream($view, array $parameters = array(), StreamedResponse $
323323
$twig->display($view, $parameters);
324324
};
325325
} else {
326-
throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available.');
326+
throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available. Try running "composer require twig".');
327327
}
328328

329329
if (null === $response) {
@@ -373,7 +373,7 @@ protected function createNotFoundException($message = 'Not Found', \Exception $p
373373
protected function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null)
374374
{
375375
if (!class_exists(AccessDeniedException::class)) {
376-
throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available.');
376+
throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require security".');
377377
}
378378

379379
return new AccessDeniedException($message, $previous);
@@ -422,7 +422,7 @@ protected function createFormBuilder($data = null, array $options = array())
422422
protected function getDoctrine()
423423
{
424424
if (!$this->container->has('doctrine')) {
425-
throw new \LogicException('The DoctrineBundle is not registered in your application.');
425+
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require doctrine".');
426426
}
427427

428428
return $this->container->get('doctrine');
@@ -442,7 +442,7 @@ protected function getDoctrine()
442442
protected function getUser()
443443
{
444444
if (!$this->container->has('security.token_storage')) {
445-
throw new \LogicException('The SecurityBundle is not registered in your application.');
445+
throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require security".');
446446
}
447447

448448
if (null === $token = $this->container->get('security.token_storage')->getToken()) {
@@ -470,7 +470,7 @@ protected function getUser()
470470
protected function isCsrfTokenValid($id, $token)
471471
{
472472
if (!$this->container->has('security.csrf.token_manager')) {
473-
throw new \LogicException('CSRF protection is not enabled in your application.');
473+
throw new \LogicException('CSRF protection is not enabled in your application. Enable it with the "csrf_protection" key in "config/packages/framework.yaml".');
474474
}
475475

476476
return $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($id, $token));

0 commit comments

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