5 * Helper module for testing EntityFieldQuery access on any type of entity.
9 * Implements hook_menu().
11 function entity_query_access_test_menu() {
12 $items['entity-query-access/test/%'] = array(
13 'title' => "Retrieve a sample of entity query access data",
14 'page callback' => 'entity_query_access_test_sample_query',
15 'page arguments' => array(2),
16 'access callback' => TRUE,
17 'type' => MENU_CALLBACK,
24 * Returns the results from an example EntityFieldQuery.
26 function entity_query_access_test_sample_query($field_name) {
29 // Simulate user does not have access to view all nodes.
30 $access = &drupal_static('node_access_view_all_nodes');
31 $access[$user->uid] = FALSE;
33 $query = new EntityFieldQuery();
35 ->entityCondition('entity_type', 'test_entity_bundle_key')
36 ->fieldCondition($field_name, 'value', 0, '>')
37 ->entityOrderBy('entity_id', 'ASC');
40 'title' => t('EntityFieldQuery results'),
42 foreach ($query->execute() as $entity_type => $entity_ids) {
43 foreach ($entity_ids as $entity_id => $entity_stub) {
44 $results['items'][] = format_string('Found entity of type @entity_type with id @entity_id', array('@entity_type' => $entity_type, '@entity_id' => $entity_id));
47 if (count($results['items']) > 0) {
48 $output = theme('item_list', $results);
51 $output = 'No results found with EntityFieldQuery.';