You are here

function access_grant_view in Access Control Kit 7

Generates a renderable array for an access grant.

Parameters

object $grant: An access grant.

string $view_mode: (optional) The view mode. Defaults to 'full'.

string|null $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Return value

array An array in the format expected by drupal_render().

See also

drupal_render()

1 call to access_grant_view()
access_grant_view_multiple in ./access.module
Constructs an array for drupal_render() from an array of access grants.
1 string reference to 'access_grant_view'
access_hook_info in ./access.module
Implements hook_hook_info().

File

./access.module, line 257
The access control kit module.

Code

function access_grant_view($grant, $view_mode = 'full', $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }

  // Retrieve all fields and attach to $grant->content.
  access_grant_build_content($grant, $view_mode, $langcode);
  $build = $grant->content;

  // We don't need it twice.
  unset($grant->content);
  $build += array(
    '#theme' => 'access_grant',
    '#access_grant' => $grant,
    '#view_mode' => $view_mode,
    '#language' => $langcode,
  );
  $type = 'access_grant';
  drupal_alter(array(
    'access_grant_view',
    'entity_view',
  ), $build, $type);
  return $build;
}