8000 Backport Flex-specific error messages in controller shortcuts to 3.4 by chalasr · Pull Request #25636 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Backport Flex-specific error messages in controller shortcuts to 3.4 #25636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Proposing Flex-specific error messages in the controller shortcuts
  • Loading branch information
weaverryan authored and chalasr committed Jan 3, 2018
commit 419e93465fbe28f9a5d4a1fa93b94e1d77e73061
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected function file($file, $fileName = null, $disposition = ResponseHeaderBa
protected function addFlash($type, $message)
{
if (!$this->container->has('session')) {
throw new \LogicException('You can not use the addFlash method if sessions are disabled.');
throw new \LogicException('You can not use the addFlash method if sessions are disabled. Enable them in "config/packages/framework.yaml".');
}

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

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

if (!$this->container->has('twig')) {
throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available.');
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".');
}

return $this->container->get('twig')->render($view, $parameters);
Expand All @@ -285,7 +285,7 @@ protected function render($view, array $parameters = array(), Response $response
} elseif ($this->container->has('twig')) {
$content = $this->container->get('twig')->render($view, $parameters);
} else {
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.');
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".');
}

if (null === $response) {
Expand Down Expand Up @@ -323,7 +323,7 @@ protected function stream($view, array $parameters = array(), StreamedResponse $
$twig->display($view, $parameters);
};
} else {
throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available.');
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".');
}

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

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

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

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

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