You are here

public function NodeAccessTestAutoBubblingController::latest in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php \Drupal\node_access_test_auto_bubbling\Controller\NodeAccessTestAutoBubblingController::latest()

Lists the three latest published node IDs.

Return value

array A render array.

1 string reference to 'NodeAccessTestAutoBubblingController::latest'
node_access_test_auto_bubbling.routing.yml in core/modules/node/tests/node_access_test_auto_bubbling/node_access_test_auto_bubbling.routing.yml
core/modules/node/tests/node_access_test_auto_bubbling/node_access_test_auto_bubbling.routing.yml

File

core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php, line 52
Contains \Drupal\node_access_test_auto_bubbling\Controller\NodeAccessTestAutoBubblingController.

Class

NodeAccessTestAutoBubblingController
Returns a node ID listing.

Namespace

Drupal\node_access_test_auto_bubbling\Controller

Code

public function latest() {
  $nids = $this->entityQuery
    ->get('node')
    ->condition('status', NODE_PUBLISHED)
    ->sort('created', 'DESC')
    ->range(0, 3)
    ->execute();
  return [
    '#markup' => $this
      ->t('The three latest nodes are: @nids.', [
      '@nids' => implode(', ', $nids),
    ]),
  ];
}