Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
a439ae7f
Commit
a439ae7f
authored
Jun 17, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added traits for the routes
parent
3266c735
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
src/Silex/Route/SecurityTrait.php
src/Silex/Route/SecurityTrait.php
+31
-0
No files found.
src/Silex/Route/SecurityTrait.php
0 → 100644
View file @
a439ae7f
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Silex\Route
;
use
Symfony\Component\Security\Core\Exception\AccessDeniedException
;
/**
* Security trait.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
trait
SecurityTrait
{
public
function
secure
(
$roles
)
{
$this
->
before
(
function
(
$request
,
$app
)
use
(
$roles
)
{
if
(
!
$app
[
'security'
]
->
isGranted
(
$roles
))
{
throw
new
AccessDeniedException
();
}
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment