You are here

public function NodeAccessTestAutoBubblingController::latest in Drupal 8

Same name and namespace in other branches
  1. 9 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 20

Class

NodeAccessTestAutoBubblingController
Returns a node ID listing.

Namespace

Drupal\node_access_test_auto_bubbling\Controller

Code

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