public function NodeRevisionDelete::getCandidatesRevisionsByNumber in Node Revision Delete 8
Return a number of candidate revisions to be deleted.
Parameters
int $number: The number of revisions to return.
Return value
array Array of vids.
Overrides NodeRevisionDeleteInterface::getCandidatesRevisionsByNumber
File
- src/
NodeRevisionDelete.php, line 289
Class
- NodeRevisionDelete
- Class NodeRevisionDelete.
Namespace
Drupal\node_revision_deleteCode
public function getCandidatesRevisionsByNumber($number) {
if (!is_int($number) && $number < 0) {
throw new \InvalidArgumentException("\$number parameter must be a positive integer");
}
// Looking for all the configured content types.
$content_types = $this
->getConfiguredContentTypes();
$revisions = [];
foreach ($content_types as $content_type) {
// Getting the revisions.
$revisions = array_merge($revisions, $this
->getCandidatesRevisions($content_type
->id(), $number));
// Getting the number of revision we will delete.
if ($number < count($revisions)) {
$revisions = array_slice($revisions, 0, $number, TRUE);
break;
}
}
return $revisions;
}