class SocialEventManagersAccessHelper in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.2 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.3 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.4 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.5 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.6 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.7 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 8.8 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 10.3.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 10.0.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 10.1.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
- 10.2.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper
Helper class for checking update access on event managers nodes.
Hierarchy
- class \Drupal\social_event_managers\SocialEventManagersAccessHelper
Expanded class hierarchy of SocialEventManagersAccessHelper
1 file declares its use of SocialEventManagersAccessHelper
- social_event_managers.module in modules/
social_features/ social_event/ modules/ social_event_managers/ social_event_managers.module - Contains social_event_managers.module.
File
- modules/
social_features/ social_event/ modules/ social_event_managers/ src/ SocialEventManagersAccessHelper.php, line 12
Namespace
Drupal\social_event_managersView source
class SocialEventManagersAccessHelper {
/**
* NodeAccessCheck for given operation, node and user account.
*/
public static function nodeAccessCheck(NodeInterface $node, $op, AccountInterface $account) {
if ($op === 'update') {
// Only for events.
if ($node
->getType() === 'event') {
// Only continue if the user has access to view the event.
if ($node
->access('view', $account)) {
$event_managers = $node
->get('field_event_managers')
->getValue();
foreach ($event_managers as $event_manager) {
if ($account
->id() == $event_manager['target_id']) {
return 2;
}
}
// No hits, so we assume the user is not an event manager.
return 1;
}
}
}
return 0;
}
/**
* Gets the Entity access for the given node.
*/
public static function getEntityAccessResult(NodeInterface $node, $op, AccountInterface $account) {
$access = SocialEventManagersAccessHelper::nodeAccessCheck($node, $op, $account);
switch ($access) {
case 2:
return AccessResult::allowed()
->cachePerPermissions()
->addCacheableDependency($node);
case 1:
return AccessResult::forbidden();
}
return AccessResult::neutral();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialEventManagersAccessHelper:: |
public static | function | Gets the Entity access for the given node. | |
SocialEventManagersAccessHelper:: |
public static | function | NodeAccessCheck for given operation, node and user account. |