You are here

function pmnote_pm_contextual_links in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmnote/pmnote.module \pmnote_pm_contextual_links()

Implements hook_pm_contextual_links().

File

pmnote/pmnote.module, line 79
Functions for the PM Note module.

Code

function pmnote_pm_contextual_links($entity, $type, $view_mode, $langcode) {
  $links = array();
  list($id, $vid, $bundle) = entity_extract_ids($type, $entity);
  if ($type == 'node') {
    $field_info = field_info_field('pmnote_parent');
    $target_bundles = $field_info['settings']['handler_settings']['target_bundles'];
    if (in_array($bundle, $target_bundles)) {
      $links[t('Add Note')] = array(
        'title' => t('Add Note'),
        'href' => 'node/add/pmnote',
        'query' => array(
          'pmnote_parent' => $id,
        ),
      );
    }
  }
  return $links;
}