You are here

private function EntityPagerOut::tokenLink in Entity Pager 7

Process Token link.

The 'All' link can have tokens set in it in the Views > settings form 'Entity Pager' section. This function processes the values added. E.g. it can turn things like entity references into Titles with links.

Parameters

string $entity_type: The type of entity.

object $entity: The entity object.

string $url: The url to be added to link.

string $title: The title for the link.

1 call to EntityPagerOut::tokenLink()
EntityPagerOut::getEntityPager in includes/EntityPagerOut.inc
Entity Pager return links.

File

includes/EntityPagerOut.inc, line 72
Provides the Business Logic for the EntityPager module.

Class

EntityPagerOut
Class EntityPagerOut.

Code

private function tokenLink($entity_type, $entity, $url, $title) {
  $detokened = array();
  $detokened['url'] = token_replace($url, array(
    $entity_type => $entity,
  ));
  $detokened['title'] = token_replace($title, array(
    $entity_type => $entity,
  ));
  if ($detokened['url'] == $url) {

    // No tokens used.
    $new_url = $url;
  }
  elseif (drupal_valid_path($detokened['url'])) {

    // A valid url e.g. edit node.
    $new_url = $detokened['url'];
  }
  else {

    // Entity reference process.
    $new_url = $this
      ->entityRefUrlFromToken($entity_type, $entity, $url);
  }
  $this
    ->setAllUrl($new_url);
  $this
    ->setAllTitle($detokened['title']);
}