Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite1b85db

Browse files
committed
feature#9405 [FrameworkBundle] Added a helper method to create AccessDeniedException (klaussilveira)
This PR was squashed before being merged into the 2.5-dev branch (closes#9405).Discussion----------[FrameworkBundle] Added a helper method to create AccessDeniedExceptionJust a small helper method that has been missing, since the addition of createNotFoundException().| Q | A| ------------- | ---| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets || License | MIT| Doc PR |Commits-------183d0ec [FrameworkBundle] Added a helper method to create AccessDeniedException
2 parents7da803f +183d0ec commite1b85db

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
useSymfony\Component\DependencyInjection\ContainerAware;
1919
useSymfony\Component\HttpKernel\Exception\NotFoundHttpException;
2020
useSymfony\Component\HttpKernel\HttpKernelInterface;
21+
useSymfony\Component\Security\Core\Exception\AccessDeniedException;
2122
useSymfony\Component\Form\FormTypeInterface;
2223
useSymfony\Component\Form\Form;
2324
useSymfony\Component\Form\FormBuilder;
@@ -139,8 +140,8 @@ public function stream($view, array $parameters = array(), StreamedResponse $res
139140
*
140141
* throw $this->createNotFoundException('Page not found!');
141142
*
142-
* @param string $message A message
143-
* @param \Exception $previous The previous exception
143+
* @param string$message A message
144+
* @param \Exception|null $previous The previous exception
144145
*
145146
* @return NotFoundHttpException
146147
*/
@@ -149,6 +150,23 @@ public function createNotFoundException($message = 'Not Found', \Exception $prev
149150
returnnewNotFoundHttpException($message,$previous);
150151
}
151152

153+
/**
154+
* Returns an AccessDeniedException.
155+
*
156+
* This will result in a 403 response code. Usage example:
157+
*
158+
* throw $this->createAccessDeniedException('Unable to access this page!');
159+
*
160+
* @param string $message A message
161+
* @param \Exception|null $previous The previous exception
162+
*
163+
* @return AccessDeniedException
164+
*/
165+
publicfunctioncreateAccessDeniedException($message ='Access Denied',\Exception$previous =null)
166+
{
167+
returnnewAccessDeniedException($message,$previous);
168+
}
169+
152170
/**
153171
* Creates and returns a Form instance from the type of the form.
154172
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp