You are here

function commerce_pricelist_list_view in Commerce Pricelist 7

Menu callback to display an entity.

As we load the entity for display, we're responsible for invoking a number of hooks in their proper order.

See also

hook_entity_prepare_view()

hook_entity_view()

hook_entity_view_alter()

1 string reference to 'commerce_pricelist_list_view'
commerce_pricelist_menu in ./commerce_pricelist.module
Implements hook_menu().

File

includes/commerce_pricelist.admin.inc, line 38
Summary

Code

function commerce_pricelist_list_view($entity, $view_mode = 'full') {

  // Our entity type, for convenience.
  $entity_type = 'commerce_pricelist_list';

  // Start setting up the content.
  $entity->content = array(
    '#view_mode' => $view_mode,
  );

  // We call entity_prepare_view() so it can invoke hook_entity_prepare_view()
  // for us.
  entity_prepare_view($entity_type, array(
    $entity->list_id => $entity,
  ));
  $pricelist_items = commerce_pricelist_item_list_entities($entity->list_id);
  $entity->content['pricelist_items'] = $pricelist_items;

  // Now to invoke some hooks. We need the language code for
  // hook_entity_view(), so let's get that.
  global $language;
  $langcode = $language->language;

  // And now invoke hook_entity_view().
  module_invoke_all('entity_view', $entity, $entity_type, $view_mode, $langcode);

  // Now invoke hook_entity_view_alter().
  drupal_alter(array(
    'commerce_pricelist_list_view',
    'entity_view',
  ), $entity->content, $entity_type);

  // And finally return the content.
  return $entity->content;
}