Skip to content

Instantly share code, notes, and snippets.

@firstval
Forked from ranelpadon/toolkit.drush.inc.php
Last active August 29, 2015 14:12
Show Gist options
  • Save firstval/edca8c2cc9876dacc91c to your computer and use it in GitHub Desktop.
Save firstval/edca8c2cc9876dacc91c to your computer and use it in GitHub Desktop.
<?php
/**
* Implements COMMANDFILE_drush_command().
*/
function toolkit_drush_command() {
$items = array();
// Command for Clear Cache All.
// The 'cca' array key is what you type in the terminal, like: drush cca.
// This will be a shortcut for drush cc all.
$items['cca'] = array(
'description' => "Clear all cached data. Similar to hitting the 'Clear cache' button in Drupal.",
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
);
// Command for Node Load.
$items['nl'] = array(
'description' => "Load a node given its node ID.",
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
);
return $items;
}
/**
* Implements drush_COMMANDFILE_COMMANDNAME.
*
* Purpose: Clear Drupal's entire cache.
* Syntax: drush cca
* Related Command: drush cc all.
*/
function drush_toolkit_cca() {
// Call the Drupal API's function for clearing the site's cache.
drupal_flush_all_caches();
// Display some notifications in the terminal.
drush_print("All caches have been cleared! Ready for more action!");
}
/**
* Implements drush_COMMANDFILE_COMMANDNAME.
*
* Purpose: Load a node to view/analyze its properties/values.
* Syntax: drush nl NODE_ID
* Related Command: drush php-eval 'var_export(node_load(NODE_ID));'
*/
function drush_toolkit_nl($nid) {
// Call the Drupal API's function for loading a node.
$node_object = node_load($nid);
// Display the object's attributes in terminal.
// drush_print(var_export($node_object) is redundant.
// drush_print($node_object) will not work since drush_print is for simple texts only.
var_export($node_object);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment