Page callback: Creates the node access entity test page.
Page should say "No nodes" if there are no nodes, and "Yes, # nodes" (with the number filled in) if there were nodes the user could access. Also, the database query is shown, and a list of the node IDs, for debugging purposes. And if there is a query exception, the page says "Exception" and gives the error.
function node_access_entity_test_page() {
$output = '';
try {
$result = Drupal::entityQuery('node')
->condition('body.value', 'A', 'STARTS_WITH')
->execute();
if (!empty($result)) {
$output .= '<p>Yes, ' . count($result) . ' nodes</p>';
$output .= '<ul>';
foreach ($result as $nid) {
$output .= '<li>' . $nid . '</li>';
}
$output .= '</ul>';
}
else {
$output .= '<p>No nodes</p>';
}
} catch (Exception $e) {
$output = '<p>Exception</p>';
$output .= '<p>' . $e
->getMessage() . '</p>';
}
return $output;
}