You are here

public function AlphaPaginationCharacter::buildLink in Views Alpha Pagination 7.2

Builds a link render array based on current text, value and options.

Parameters

array $options: Optional. Array of options to pass to url().

Return value

array A render array for the link.

1 call to AlphaPaginationCharacter::buildLink()
AlphaPaginationCharacter::build in src/AlphaPaginationCharacter.php
Builds a render array of the character.

File

src/AlphaPaginationCharacter.php, line 100

Class

AlphaPaginationCharacter
Class AlphaPaginationCharacter.

Code

public function buildLink(array $options = []) {

  // Merge in options.
  $options = drupal_array_merge_deep([
    'attributes' => [],
    'html' => FALSE,
    'query' => drupal_get_query_parameters(),
  ], $options);

  // Merge in classes.
  $this->alphaPagination
    ->addClasses($this
    ->getOption('paginate_link_class'), $options['attributes']);
  $tokens = $this->alphaPagination
    ->getTokens($this
    ->getValue());
  $path = token_replace($this
    ->getOption('paginate_link_path'), $tokens);

  // Determine if link is external (automatically enforcing for anchors).
  if ($this
    ->getOption('paginate_link_external') || $path && $path[0] === '#') {
    $options['external'] = TRUE;
  }

  // Add in additional attributes.
  if ($this
    ->getOption('paginate_link_attributes')) {
    $attributes = $this->alphaPagination
      ->parseAttributes($this
      ->getOption('paginate_link_attributes'), $tokens);

    // Remove any class attributes (should use the dedicated class option).
    unset($attributes['class']);

    // Merge in the attributes.
    $options['attributes'] = drupal_array_merge_deep($options['attributes'], $attributes);
  }

  // Build link render array.
  return [
    '#theme' => 'link__alpha_pagination',
    '#text' => $this
      ->getLabel(),
    '#path' => $path,
    '#options' => $options,
  ];
}