use Drupal\node\Entity\Node;
$node = \Drupal::routeMatch()->getParameter('node');
// Here article is the node type.
$nids = \Drupal::entityQuery('node')
->condition('type', 'article')
->accessCheck(TRUE)
->execute();
// Get the list of nodes
$nodes = Node::loadMultiple($nids);
// You can use the delete function of the node
foreach($nodes as $node) {
$node->delete();
}
- Log in to post comments
Category