function NodeAccessTestAutoBubblingController::latest

Same name in other branches
  1. 8.9.x core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php \Drupal\node_access_test_auto_bubbling\Controller\NodeAccessTestAutoBubblingController::latest()
  2. 10 core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php \Drupal\node_access_test_auto_bubbling\Controller\NodeAccessTestAutoBubblingController::latest()
  3. 11.x 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()
        ->accessCheck(TRUE)
        ->condition('status', NodeInterface::PUBLISHED)
        ->sort('created', 'DESC')
        ->range(0, 3)
        ->execute();
    return [
        '#markup' => $this->t('The three latest nodes are: @nids.', [
            '@nids' => implode(', ', $nids),
        ]),
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.