You are here

function gdpr_tasks_tokens in General Data Protection Regulation 7

Implements hook_tokens().

File

modules/gdpr_tasks/gdpr_tasks.module, line 303
Module file for the GDPR Tasks module.

Code

function gdpr_tasks_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'gdpr_task_type');
  $results = $query
    ->execute();
  $keys = array_keys($results['gdpr_task_type']);
  foreach (entity_load('gdpr_task_type', $keys) as $task_type) {
    if ($type == 'gdpr_task') {
      foreach ($tokens as $name => $original) {
        switch ($name) {
          case 'type':
            $entity = reset($data);
            $replacements[$original] = entity_label('gdpr_task_type', $task_type);
            break;
        }
      }
    }
  }
  return $replacements;
}