You are here

function rules_link_tokens in Rules Link 7

Same name and namespace in other branches
  1. 7.2 rules_link.module \rules_link_tokens()

Implements hook_tokens().

File

./rules_link.module, line 611
Rules Link - module file.

Code

function rules_link_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $url_options = array(
    'absolute' => TRUE,
  );
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
    $language_code = $options['language']->language;
  }
  else {
    $language_code = NULL;
  }
  $sanitize = !empty($options['sanitize']);
  $replacements = array();
  $entities = entity_get_info();
  if (isset($entities[$type]) && !empty($data[$type])) {
    $entity = $data[$type];
    list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'rules_link_token':
          $replacements[$original] = rules_link_get_token($id);
          break;
      }
    }
  }
  return $replacements;
}