class AddEnrolleeAccessCheck in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 8.6 modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 8.7 modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 10.3.x modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 10.0.x modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 10.1.x modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
- 10.2.x modules/social_features/social_event/modules/social_event_managers/src/Access/AddEnrolleeAccessCheck.php \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
Determines access to routes based on manage everything enrollments.
Hierarchy
- class \Drupal\social_event_managers\Access\AddEnrolleeAccessCheck implements AccessInterface
Expanded class hierarchy of AddEnrolleeAccessCheck
1 string reference to 'AddEnrolleeAccessCheck'
- social_event_managers.services.yml in modules/
social_features/ social_event/ modules/ social_event_managers/ social_event_managers.services.yml - modules/social_features/social_event/modules/social_event_managers/social_event_managers.services.yml
1 service uses AddEnrolleeAccessCheck
- social_event_managers.add_enrollee.permission in modules/
social_features/ social_event/ modules/ social_event_managers/ social_event_managers.services.yml - Drupal\social_event_managers\Access\AddEnrolleeAccessCheck
File
- modules/
social_features/ social_event/ modules/ social_event_managers/ src/ Access/ AddEnrolleeAccessCheck.php, line 19
Namespace
Drupal\social_event_managers\AccessView source
class AddEnrolleeAccessCheck implements AccessInterface {
/**
* Checks access.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The parametrized route.
* @param \Drupal\Core\Session\AccountInterface $account
* The account to check access for.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
$permission = $route
->getRequirement('_enrollee_permission');
// Don't interfere if no permission was specified.
// Or it's not the permission we are looking for.
if ($permission === NULL || $permission !== 'manage everything enrollments') {
return AccessResult::neutral();
}
// Don't interfere if no group was specified.
$parameters = $route_match
->getParameters();
if (!$parameters
->has('node')) {
return AccessResult::neutral();
}
// Don't interfere if the group isn't a real group.
$node = $parameters
->get('node');
if (!is_null($node) && !$node instanceof Node) {
$node = Node::load($node);
}
if (!$node instanceof NodeInterface) {
return AccessResult::neutral();
}
// A user with this access can definitely do everything.
if ($account
->hasPermission('manage everything enrollments')) {
return AccessResult::allowed();
}
$type = $node
->getType();
// Don't interfere if it's not an event.
if ($type !== 'event') {
return AccessResult::neutral();
}
// AN Users aren't allowed anything.
if (!$account
->isAuthenticated()) {
return AccessResult::forbidden();
}
// Lets return the correct access for our Event Manager.
$managers_access = SocialEventManagersAccessHelper::getEntityAccessResult($node, 'update', $account);
if ($managers_access instanceof AccessResultAllowed || $managers_access instanceof AccessResultForbidden) {
return $managers_access
->addCacheableDependency($node);
}
// We allow it but lets add the group as dependency to the cache
// now because field value might be edited and cache should
// clear accordingly.
return AccessResult::neutral();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AddEnrolleeAccessCheck:: |
public | function | Checks access. |