You are here

function organigrams_tokens in Organigrams 7

Same name and namespace in other branches
  1. 8.2 organigrams.module \organigrams_tokens()
  2. 8 organigrams.module \organigrams_tokens()

Implements hook_tokens().

File

./organigrams.module, line 2042
Defines the organigrams functions and entity types.

Code

function organigrams_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  // Replace the organigrams tokens with actual organigrams.
  if ($type == 'organigrams') {
    foreach ($tokens as $name => $original) {
      $organigram = organigrams_machine_name_load($name);
      if (!empty($organigram)) {
        $organigram_renderable_array = entity_view('organigrams', array(
          $organigram,
        ), 'organigram_block');
        $replacements[$original] = render($organigram_renderable_array);
      }
    }
  }
  return $replacements;
}