Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chill-project
Chill-Report
Commits
c120c934
Commit
c120c934
authored
Sep 14, 2015
by
Julien Fastré
Browse files
switch to role declaration in code
parent
7fba3535
Changes
3
Hide whitespace changes
Inline
Side-by-side
DependencyInjection/ChillReportExtension.php
View file @
c120c934
...
...
@@ -97,16 +97,6 @@ class ChillReportExtension extends Extension implements PrependExtensionInterfac
$this
->
declareReportAsCustomizable
(
$container
);
$this
->
declareRouting
(
$container
);
$this
->
prependRoleHierarchy
(
$container
);
$this
->
declareRoles
(
$container
);
}
protected
function
declareRoles
(
ContainerBuilder
$container
)
{
$container
->
prependExtensionConfig
(
'chill_main'
,
array
(
'available_roles'
=>
array
(
'CHILL_REPORT_UPDATE'
,
'CHILL_REPORT_SEE'
,
'CHILL_REPORT_CREATE'
)
));
}
}
Resources/config/services.yml
View file @
c120c934
...
...
@@ -30,6 +30,7 @@ services:
-
"
@chill.main.security.authorization.helper"
tags
:
-
{
name
:
security.voter
}
-
{
name
:
chill.role
}
chill.report.form.report_type
:
class
:
Chill\ReportBundle\Form\ReportType
...
...
Security/Authorization/ReportVoter.php
View file @
c120c934
...
...
@@ -21,13 +21,14 @@ namespace Chill\ReportBundle\Security\Authorization;
use
Chill\MainBundle\Security\Authorization\AbstractChillVoter
;
use
Chill\MainBundle\Security\Authorization\AuthorizationHelper
;
use
Chill\MainBundle\Security\ProvideRoleInterface
;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class
ReportVoter
extends
AbstractChillVoter
class
ReportVoter
extends
AbstractChillVoter
implements
ProvideRoleInterface
{
const
CREATE
=
'CHILL_REPORT_CREATE'
;
const
SEE
=
'CHILL_REPORT_SEE'
;
...
...
@@ -63,4 +64,15 @@ class ReportVoter extends AbstractChillVoter
return
$this
->
helper
->
userHasAccess
(
$user
,
$report
,
$attribute
);
}
public
function
getRoles
()
{
return
$this
->
getSupportedAttributes
();
}
public
function
getRolesWithoutScope
()
{
return
array
();
}
}
Write
Preview
Supports
Markdown
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