module_grants_entity_test.module in Module Grants 7
We need this module to create a page to test entity access
File
tests/module_grants_entity_test.moduleView source
<?php
/**
* @file
* We need this module to create a page to test entity access
*/
/**
* Implements hook_menu().
*
* Sets up a page that call entity_access().
*/
function module_grants_entity_test_menu() {
$items = array();
$items['entity_access_test_page'] = array(
'title' => 'Entity access test',
'page callback' => 'module_grants_entity_test_entity_access_test_page',
'access arguments' => array(
'access content',
),
'type' => MENU_SUGGESTED_ITEM,
);
return $items;
}
/**
* Page callback for node access test page.
*
* Page should say "No" if user has no access to entity_access('view', 'node'),
* "Yes" otherwise.
*/
function module_grants_entity_test_entity_access_test_page() {
$output = '';
try {
$output .= '<p>' . (entity_access('view', 'node') ? 'Yes' : 'No') . '</p>';
} catch (Exception $e) {
$output = '<p>Exception</p>';
$output .= '<p>' . $e
->getMessage() . '</p>';
}
return $output;
}
Functions
Name | Description |
---|---|
module_grants_entity_test_entity_access_test_page | Page callback for node access test page. |
module_grants_entity_test_menu | Implements hook_menu(). |