public function checkPermissions($node) {
    switch ($node->getType()) {
      case 'campaign':
        $campaign = $node;
        break;

      case 'campaign_page':
        $campaign = $this->getCampaignNodeFromRoute();
        break;

      default:
        return FALSE;
    }

    // Get full menu from the Campaign node.
    $campaignMenu = $campaign->get('field_campaign_menu')->getValue();
    if (!empty($campaignMenu)) {
      $campaignMenu = unserialize($campaign->field_campaign_menu->value);
    }

    if (empty($campaignMenu)) {
      return FALSE;
    }

    $landingPage = $this->getActiveCampaignPage($campaign);

    // Show Pause page without the permissions check.
    if ($campaign->get('field_pause_campaign')->value) {
      return TRUE;
    }

    if ($node->getType() == 'campaign') {
      $pageId = $landingPage->id();
    }
    else {
      $pageId = $node->id();
    }
    foreach ($campaignMenu[$landingPage->id()]['links'] as $k => $link) {
      if (empty($link['page'])) {
        continue;
      }
      $linkPageId = $link['page'][0]['target_id'];
      if ($linkPageId != $pageId) {
        continue;
      }
      return !$link['logged'] || MemberCampaign::isLoggedIn($campaign->id());

      break;
    }
    return FALSE;
  }
public function checkPermissions($node) {
    switch ($node->getType()) {
      case 'campaign':
        $campaign = $node;
        break;

      case 'campaign_page':
        $campaign = $this->getCampaignNodeFromRoute();
        break;

      default:
        return FALSE;
    }

    // Get full menu from the Campaign node.
    $campaignMenu = $campaign->get('field_campaign_menu')->getValue();
    if (!empty($campaignMenu)) {
      $campaignMenu = unserialize($campaign->field_campaign_menu->value);
    }

    if (empty($campaignMenu)) {
      return FALSE;
    }

    $landingPage = $this->getActiveCampaignPage($campaign);

    // Show Pause page without the permissions check.
    if ($campaign->get('field_pause_campaign')->value) {
      return TRUE;
    }

    if ($node->getType() == 'campaign') {
      $pageId = $landingPage->id();
    }
    else {
      $pageId = $node->id();
    }
    foreach ($campaignMenu[$landingPage->id()]['links'] as $k => $link) {
      if (empty($link['page'])) {
        continue;
      }
      $linkPageId = $link['page'][0]['target_id'];
      if ($linkPageId != $pageId) {
        continue;
      }
      return !$link['logged'] || MemberCampaign::isLoggedIn($campaign->id());

      break;
    }
    return FALSE;
  }
public function checkPermissions ( $ node ) { switch ( $ node -> getType ( ) ) { case 'campaign' : $ campaign = $ node ; break ; case 'campaign_page' : $ campaign = $ this -> getCampaignNodeFromRoute ( ) ; break ; default : return FALSE ; } // Get full menu from the Campaign node. $ campaignMenu = $ campaign -> get ( 'field_campaign_menu' ) -> getValue ( ) ; if ( ! empty ( $ campaignMenu ) ) { $ campaignMenu = unserialize ( $ campaign -> field_campaign_menu -> value ) ; } if ( empty ( $ campaignMenu ) ) { return FALSE ; } $ landingPage = $ this -> getActiveCampaignPage ( $ campaign ) ; // Show Pause page without the permissions check. if ( $ campaign -> get ( 'field_pause_campaign' ) -> value ) { return TRUE ; } if ( $ node -> getType ( ) == 'campaign' ) { $ pageId = $ landingPage -> id ( ) ; } else { $ pageId = $ node -> id ( ) ; } foreach ( $ campaignMenu [ $ landingPage -> id ( ) ] [ 'links' ] as $ k => $ link ) { if ( empty ( $ link [ 'page' ] ) ) { continue ; } $ linkPageId = $ link [ 'page' ] [ 0 ] [ 'target_id' ] ; if ( $ linkPageId != $ pageId ) { continue ; } return ! $ link [ 'logged' ] || MemberCampaign :: isLoggedIn ( $ campaign -> id ( ) ) ; break ; } return FALSE ; }
Check permissions of the current page.

@param \Drupal\node\Entity\Node $node
Campaign/Campaign Page node.

@return bool
Check permissions of the current page .