You are here

function commerce_product_handler_field_product_operations::render in Commerce Core 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

modules/product/includes/views/handlers/commerce_product_handler_field_product_operations.inc, line 36

Class

commerce_product_handler_field_product_operations
Field handler to present a product's operations links.

Code

function render($values) {
  $product_id = $this
    ->get_value($values, 'product_id');

  // Get the operations links.
  $links = menu_contextual_links('commerce-product', 'admin/commerce/products', array(
    $product_id,
  ));
  if (!empty($links)) {

    // Add the destination to the links if specified.
    if ($this->options['add_destination']) {
      foreach ($links as $id => &$link) {
        $link['query'] = drupal_get_destination();
      }
    }
    drupal_add_css(drupal_get_path('module', 'commerce_product') . '/theme/commerce_product.admin.css');
    return theme('links', array(
      'links' => $links,
      'attributes' => array(
        'class' => array(
          'links',
          'inline',
          'operations',
        ),
      ),
    ));
  }
}