private function getCampaignNodeCampaignMenu(NodeInterface $campaign) {
    /** @var \Drupal\node\Entity\Node $campaign */
    if ($campaign->bundle() != 'campaign') {
      return [];
    }

    // 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 [];
    }

    /** @var \Drupal\node\Entity\Node $landingPage */
    $landingPage = $this->getActiveCampaignPage($campaign);

    if (empty($landingPage)) {
      return [];
    }

    $links = [];
    foreach ($campaignMenu[$landingPage->id()]['links'] as $k => $link) {
      if (empty($link['page'])) {
        continue;
      }
      $linkPageId = $link['page'][0]['target_id'];

      // Replace the link on the main Campaign page by the Campaign's URL.
      if ($linkPageId == $landingPage->id()) {
        $linkPageId = $campaign->id();
      }
      $needsLogin = $link['logged'] && !MemberCampaign::isLoggedIn($campaign->id());
      $links['campaign_' . $k] = [
        '#type' => 'link',
        '#title' => $link['title'],
        '#url' => !$needsLogin
          ? Url::fromRoute('entity.node.canonical', ['node' => $linkPageId])
          : Url::fromRoute('openy_campaign.member-action', ['action' => 'login', 'campaign_id' => $campaign->id()])
        ,
        '#attributes' => [
          'class' => [
            'campaign-page',
            'node-' . $linkPageId,
            'active',
            !$needsLogin ? '' : 'use-ajax login',
          ],
        ],
      ];
    }

    return $links;
  }
private function getCampaignNodeCampaignMenu(NodeInterface $campaign) {
    /** @var \Drupal\node\Entity\Node $campaign */
    if ($campaign->bundle() != 'campaign') {
      return [];
    }

    // 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 [];
    }

    /** @var \Drupal\node\Entity\Node $landingPage */
    $landingPage = $this->getActiveCampaignPage($campaign);

    if (empty($landingPage)) {
      return [];
    }

    $links = [];
    foreach ($campaignMenu[$landingPage->id()]['links'] as $k => $link) {
      if (empty($link['page'])) {
        continue;
      }
      $linkPageId = $link['page'][0]['target_id'];

      // Replace the link on the main Campaign page by the Campaign's URL.
      if ($linkPageId == $landingPage->id()) {
        $linkPageId = $campaign->id();
      }
      $needsLogin = $link['logged'] && !MemberCampaign::isLoggedIn($campaign->id());
      $links['campaign_' . $k] = [
        '#type' => 'link',
        '#title' => $link['title'],
        '#url' => !$needsLogin
          ? Url::fromRoute('entity.node.canonical', ['node' => $linkPageId])
          : Url::fromRoute('openy_campaign.member-action', ['action' => 'login', 'campaign_id' => $campaign->id()])
        ,
        '#attributes' => [
          'class' => [
            'campaign-page',
            'node-' . $linkPageId,
            'active',
            !$needsLogin ? '' : 'use-ajax login',
          ],
        ],
      ];
    }

    return $links;
  }
private function getCampaignNodeCampaignMenu ( NodeInterface $ campaign ) { /** @var \Drupal\node\Entity\Node $campaign */ if ( $ campaign -> bundle ( ) != 'campaign' ) { return [ ] ; } // 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 [ ] ; } /** @var \Drupal\node\Entity\Node $landingPage */ $ landingPage = $ this -> getActiveCampaignPage ( $ campaign ) ; if ( empty ( $ landingPage ) ) { return [ ] ; } $ links = [ ] ; foreach ( $ campaignMenu [ $ landingPage -> id ( ) ] [ 'links' ] as $ k => $ link ) { if ( empty ( $ link [ 'page' ] ) ) { continue ; } $ linkPageId = $ link [ 'page' ] [ 0 ] [ 'target_id' ] ; // Replace the link on the main Campaign page by the Campaign's URL. if ( $ linkPageId == $ landingPage -> id ( ) ) { $ linkPageId = $ campaign -> id ( ) ; } $ needsLogin = $ link [ 'logged' ] && ! MemberCampaign :: isLoggedIn ( $ campaign -> id ( ) ) ; $ links [ 'campaign_' . $ k ] = [ '#type' => 'link' , '#title' => $ link [ 'title' ] , '#url' => ! $ needsLogin ? Url :: fromRoute ( 'entity.node.canonical' , [ 'node' => $ linkPageId ] ) : Url :: fromRoute ( 'openy_campaign.member-action' , [ 'action' => 'login' , 'campaign_id' => $ campaign -> id ( ) ] ) , '#attributes' => [ 'class' => [ 'campaign-page' , 'node-' . $ linkPageId , 'active' , ! $ needsLogin ? '' : 'use-ajax login' , ] , ] , ] ; } return $ links ; }
Retrieves Campaign menu for the Campaign CT node.

@param \Drupal\node\NodeInterface $campaign
The Campaign node.

@return array
Array of menu links.
Retrieves Campaign menu for the Campaign CT node .