You are here

function flag_flag_link_content_type_render in Flag 7.3

Render callback.

File

plugins/content_types/flag_link/flag_link.inc, line 49

Code

function flag_flag_link_content_type_render($subtype, $conf, $args, $context) {
  $flag = flag_get_flag($conf['flag_name']);
  if (!$flag) {
    return;
  }
  if (empty($context->data)) {
    return;
  }

  // Get the ID of the entity.
  list($id, , ) = entity_extract_ids($flag->entity_type, $context->data);
  $link = flag_create_link($flag->name, $id);
  if (!$link) {
    return;
  }
  $block = new stdClass();
  $block->module = 'flag';
  $block->title = t('Flag link');
  $block->delta = $flag->name;
  $block->content = $link;
  return $block;
}