public function NodeRevisionsAutocleanCommands::deleteRevisionsAccordingSiteSettings in Node Revisions Autoclean 8
Deletes old revisions according to site's settings.
@command nra-delete-old-revisions @validate-module-enabled node @aliases nra:dor
File
- src/
Commands/ NodeRevisionsAutocleanCommands.php, line 56
Class
- NodeRevisionsAutocleanCommands
- Class NodeRevisionsAutocleanCommands.
Namespace
Drupal\node_revisions_autoclean\CommandsCode
public function deleteRevisionsAccordingSiteSettings() {
$nodes = $this->entityTypeManager
->getStorage('node')
->loadMultiple();
$count = 0;
foreach ($nodes as $node) {
$revisions = $this->revisionsManager
->revisionsToDelete($node);
if (count($revisions)) {
$this->revisionsManager
->deleteRevisions($revisions);
$this
->logger()
->log('success', $this
->t('@count revisions deleted for node @nid : @label', [
'@count' => count($revisions),
'@nid' => $node
->id(),
'@label' => $node
->label(),
]));
}
$count += count($revisions);
}
$this
->logger()
->log('success', $this
->t('Global : @count revisions deleted.', [
'@count' => $count,
]));
}