You are here

function access_grant_view_multiple in Access Control Kit 7

Constructs an array for drupal_render() from an array of access grants.

Parameters

array $grants: An array of grants, as returned by access_grant_load_multiple().

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

int $weight: (optional) An integer representing the weight of the first grant in the list. Defaults to 0.

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

Return value

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

See also

drupal_render()

2 calls to access_grant_view_multiple()
AccessGrantFunctionTest::testGrantRender in ./access.test
Test the access grant rendering functions.
access_grant_page in ./access.pages.inc
Menu page callback to view a single access grant.

File

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

Code

function access_grant_view_multiple($grants, $view_mode = 'full', $weight = 0, $langcode = NULL) {
  field_attach_prepare_view('access_grant', $grants, $view_mode, $langcode);
  entity_prepare_view('access_grant', $grants, $langcode);
  $build = array();
  foreach ($grants as $grant) {
    $build['grants'][$grant->gid] = access_grant_view($grant, $view_mode, $langcode);
    $build['grants'][$grant->gid]['#weight'] = $weight;
    $weight++;
  }
  $build['grants']['#sorted'] = TRUE;
  return $build;
}