Skip to content
Snippets Groups Projects
Commit bb443689 authored by dpi's avatar dpi
Browse files

Fixed incorrect usage of access control handlers.

parent cabf1a0e
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
......
......@@ -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()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment