function drush_node_revision_delete_validate in Node Revision Delete 7.2
Same name and namespace in other branches
- 8 node_revision_delete.drush.inc \drush_node_revision_delete_validate()
- 7.3 node_revision_delete.drush.inc \drush_node_revision_delete_validate()
Implements drush_hook_COMMAND_validate().
File
- ./
node_revision_delete.drush.inc, line 47 - Drush integration for node_revision_delete.
Code
function drush_node_revision_delete_validate($content_type, $revisions_to_keep) {
// Make sure the content type exists.
$content_types = array_keys(node_type_get_types());
if (!in_array($content_type, $content_types)) {
drush_set_error('NODE_REVISION_DELETE_WRONG_TYPE', dt('The content type "@type" does not exist. Available content types are @types', array(
'@type' => $content_type,
'@types' => implode(', ', $content_types),
)));
}
// Make sure the number of revisions is a positive integer.
// Based on Drupal's element_validate_integer_positive().
if (!is_numeric($revisions_to_keep) || intval($revisions_to_keep) != $revisions_to_keep || $revisions_to_keep <= 0) {
drush_set_error('NODE_REVISION_DELETE_WRONG_REVISIONS', dt('The amount of revisions to keep must be a positive integer.'));
}
}