You are here

function node_load in Drupal 8

Same name and namespace in other branches
  1. 4 modules/node.module \node_load()
  2. 5 modules/node/node.module \node_load()
  3. 6 modules/node/node.module \node_load()
  4. 7 modules/node/node.module \node_load()

Loads a node entity from the database.

Parameters

int $nid: The node ID.

bool $reset: (optional) Whether to reset the node_load_multiple() cache. Defaults to FALSE.

Return value

\Drupal\node\NodeInterface|null A fully-populated node entity, or NULL if the node is not found.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\node\Entity\Node::load().

See also

https://www.drupal.org/node/2266845

1 call to node_load()
NodeLegacyTest::testEntityLegacyCode in core/modules/node/tests/src/Kernel/NodeLegacyTest.php
@expectedDeprecation node_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\Node::loadMultiple(). See https://www.drupal.org/node/2266845 @expectedDeprecation node_load() is deprecated in…

File

core/modules/node/node.module, line 484
The core module that allows content to be submitted to the site.

Code

function node_load($nid = NULL, $reset = FALSE) {
  @trigger_error('node_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\node\\Entity\\Node::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED);
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('node')
      ->resetCache([
      $nid,
    ]);
  }
  return Node::load($nid);
}