You are here

public static function SocialEventManagersAccessHelper::nodeAccessCheck in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  2. 8.2 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  3. 8.3 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  4. 8.4 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  5. 8.5 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  6. 8.6 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  7. 8.7 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  8. 8.8 modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  9. 10.3.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  10. 10.0.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  11. 10.1.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()
  12. 10.2.x modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php \Drupal\social_event_managers\SocialEventManagersAccessHelper::nodeAccessCheck()

NodeAccessCheck for given operation, node and user account.

1 call to SocialEventManagersAccessHelper::nodeAccessCheck()
SocialEventManagersAccessHelper::getEntityAccessResult in modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php
Gets the Entity access for the given node.

File

modules/social_features/social_event/modules/social_event_managers/src/SocialEventManagersAccessHelper.php, line 17

Class

SocialEventManagersAccessHelper
Helper class for checking update access on event managers nodes.

Namespace

Drupal\social_event_managers

Code

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;
}