Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rng-3202298
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
rng-3202298
Commits
bb443689
Commit
bb443689
authored
8 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Fixed incorrect usage of access control handlers.
parent
cabf1a0e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Access/RegistrationAddAccessCheck.php
+7
-2
7 additions, 2 deletions
src/Access/RegistrationAddAccessCheck.php
src/AccessControl/RegistrationAccessControlHandler.php
+6
-3
6 additions, 3 deletions
src/AccessControl/RegistrationAccessControlHandler.php
with
13 additions
and
5 deletions
src/Access/RegistrationAddAccessCheck.php
+
7
−
2
View file @
bb443689
...
...
@@ -41,10 +41,15 @@ class RegistrationAddAccessCheck implements AccessInterface {
* Checks new registrations are permitted on an event.
*/
public
function
access
(
Route
$route
,
RouteMatchInterface
$route_match
,
AccountInterface
$account
,
RegistrationTypeInterface
$registration_type
=
NULL
)
{
if
(
(
$event
=
$route
->
getDefault
(
'event'
))
)
{
if
(
$event
=
$route
->
getDefault
(
'event'
))
{
$context
=
[
'event'
=>
$route_match
->
getParameter
(
$event
)];
$access_control_handler
=
$this
->
entityManager
->
getAccessControlHandler
(
'registration'
);
return
$access_control_handler
->
createAccess
(
$registration_type
,
$account
,
$context
,
TRUE
);
if
(
$registration_type
)
{
return
$access_control_handler
->
createAccess
(
$registration_type
->
id
(),
$account
,
$context
,
TRUE
);
}
else
{
return
$access_control_handler
->
createAccess
(
NULL
,
$account
,
$context
,
TRUE
);
}
}
return
AccessResult
::
forbidden
();
}
...
...
This diff is collapsed.
Click to expand it.
src/AccessControl/RegistrationAccessControlHandler.php
+
6
−
3
View file @
bb443689
...
...
@@ -9,6 +9,7 @@ namespace Drupal\rng\AccessControl;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Entity\EntityAccessControlHandler
;
use
Drupal\rng\Entity\RegistrationType
;
use
Drupal\rng\RuleGrantsOperationTrait
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Entity\EntityInterface
;
...
...
@@ -77,7 +78,7 @@ class RegistrationAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*
* @param
\Drupal\rng\RegistrationTypeInterface|NULL
$entity_bundle
* @param
string
$entity_bundle
* A registration type. Or NULL if it is a registration type listing.
*/
public
function
createAccess
(
$entity_bundle
=
NULL
,
AccountInterface
$account
=
NULL
,
array
$context
=
array
(),
$return_as_object
=
FALSE
)
{
...
...
@@ -95,8 +96,10 @@ class RegistrationAccessControlHandler extends EntityAccessControlHandler {
// $entity_bundle is omitted for registration type list at
// $event_path/register
if
(
$entity_bundle
&&
!
$event_meta
->
registrationTypeIsValid
(
$entity_bundle
))
{
return
AccessResult
::
neutral
();
if
(
$entity_bundle
&&
$registration_type
=
RegistrationType
::
load
(
$entity_bundle
))
{
if
(
!
$event_meta
->
registrationTypeIsValid
(
$registration_type
))
{
return
AccessResult
::
neutral
();
}
}
// There are no registration types configured.
elseif
(
!
$event_meta
->
getRegistrationTypeIds
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment