public function generateLink($type, $nid = 0) {
    // Get destination with query string.
    $destination = \Drupal::request()->getRequestUri();
    // Create popup link url.
    if ($nid && $type == 'class') {
      // For class branches.
      $url = Url::fromRoute('openy_popups.class_branch', [
        'node' => $nid,
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    elseif ($nid && $type == 'category') {
      $url = Url::fromRoute('openy_popups.branch', [
        'node' => $nid,
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    else {
      $url = Url::fromRoute('openy_popups.branch', [
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    $link = Link::fromTextAndUrl(t('Popup link'), $url);
    $link = $link->toRenderable();
    $link['#attributes'] = [
      'class' => [
        'location-popup-link',
        'use-ajax',
        'js-hide',
      ],
      'data-dialog-type' => 'modal',
    ];
    if ($this->checkRequestParams()) {
      $link['#attributes']['class'][] = 'popup-autostart';
    }
    $link['#cache'] = [
      'contexts' => [
        'url.path',
        'url.query_args:location',
      ],
    ];
    // Fix: lazy_builder can't render by only '#type' property.
    $element_info = \Drupal::service('plugin.manager.element_info');
    return $link + $element_info->getInfo('link');
  }
public function generateLink($type, $nid = 0) {
    // Get destination with query string.
    $destination = \Drupal::request()->getRequestUri();
    // Create popup link url.
    if ($nid && $type == 'class') {
      // For class branches.
      $url = Url::fromRoute('openy_popups.class_branch', [
        'node' => $nid,
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    elseif ($nid && $type == 'category') {
      $url = Url::fromRoute('openy_popups.branch', [
        'node' => $nid,
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    else {
      $url = Url::fromRoute('openy_popups.branch', [
        'js' => 'nojs',
        'destination' => $destination,
      ]);
    }
    $link = Link::fromTextAndUrl(t('Popup link'), $url);
    $link = $link->toRenderable();
    $link['#attributes'] = [
      'class' => [
        'location-popup-link',
        'use-ajax',
        'js-hide',
      ],
      'data-dialog-type' => 'modal',
    ];
    if ($this->checkRequestParams()) {
      $link['#attributes']['class'][] = 'popup-autostart';
    }
    $link['#cache'] = [
      'contexts' => [
        'url.path',
        'url.query_args:location',
      ],
    ];
    // Fix: lazy_builder can't render by only '#type' property.
    $element_info = \Drupal::service('plugin.manager.element_info');
    return $link + $element_info->getInfo('link');
  }
public function generateLink ( $ type , $ nid = 0 ) { // Get destination with query string. $ destination = \ Drupal :: request ( ) -> getRequestUri ( ) ; // Create popup link url. if ( $ nid && $ type == 'class' ) { // For class branches. $ url = Url :: fromRoute ( 'openy_popups.class_branch' , [ 'node' => $ nid , 'js' => 'nojs' , 'destination' => $ destination , ] ) ; } elseif ( $ nid && $ type == 'category' ) { $ url = Url :: fromRoute ( 'openy_popups.branch' , [ 'node' => $ nid , 'js' => 'nojs' , 'destination' => $ destination , ] ) ; } else { $ url = Url :: fromRoute ( 'openy_popups.branch' , [ 'js' => 'nojs' , 'destination' => $ destination , ] ) ; } $ link = Link :: fromTextAndUrl ( t ( 'Popup link' ) , $ url ) ; $ link = $ link -> toRenderable ( ) ; $ link [ '#attributes' ] = [ 'class' => [ 'location-popup-link' , 'use-ajax' , 'js-hide' , ] , 'data-dialog-type' => 'modal' , ] ; if ( $ this -> checkRequestParams ( ) ) { $ link [ '#attributes' ] [ 'class' ] [ ] = 'popup-autostart' ; } $ link [ '#cache' ] = [ 'contexts' => [ 'url.path' , 'url.query_args:location' , ] , ] ; // Fix: lazy_builder can't render by only '#type' property. $ element_info = \ Drupal :: service ( 'plugin.manager.element_info' ) ; return $ link + $ element_info -> getInfo ( 'link' ) ; }
Generate link for My YMCA location.

@param string $type
Type of link.
@param int $nid
Class node ID.

@return array
Render array with link.
Generate link for My YMCA location .