devel.drush.inc

  1. cis7 sites/all/modules/ulmus/devel/devel.drush.inc
  2. cle7 sites/all/modules/ulmus/devel/devel.drush.inc
  3. ecd7 sites/all/modules/ulmus/devel/devel.drush.inc
  4. elmsmedia7 sites/all/modules/ulmus/devel/devel.drush.inc
  5. harmony7 sites/all/modules/ulmus/devel/devel.drush.inc
  6. icor7 sites/all/modules/ulmus/devel/devel.drush.inc
  7. meedjum_blog7 sites/all/modules/ulmus/devel/devel.drush.inc
  8. mooc7 sites/all/modules/ulmus/devel/devel.drush.inc

Drush integration for the devel module.

Functions

Namesort descending Description
devel_drush_command Implements hook_drush_command().
drush_devel_download A command callback.
drush_devel_fn_hook Command handler. Show hook implementations.
drush_devel_fn_view Command handler. Show source code of specified function or method.
drush_devel_post_pm_enable Implements drush_MODULE_post_COMMAND().
drush_devel_reinstall A command callback. This is faster than 3 separate bootstraps.
drush_devel_token Command callback. List available tokens.
_drush_devel_print_function Print the specified function, including any doxygen-style comments that come before it.

File

sites/all/modules/ulmus/devel/devel.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Drush integration for the devel module.
  5. */
  6. /**
  7. * Implements hook_drush_command().
  8. */
  9. function devel_drush_command() {
  10. $items['devel-download'] = array(
  11. 'description' => dt('Downloads the FirePHP library from http://firephp.org/.'),
  12. 'arguments' => array(
  13. 'path' => dt('Optional. A path to the download folder. If omitted Drush will use the default location (sites/all/libraries/firephp).'),
  14. ),
  15. );
  16. $items['devel-reinstall'] = array(
  17. 'description' => dt('Disable, Uninstall, and Install a list of projects.'),
  18. 'arguments' => array(
  19. 'projects' => dt('A space-separated list of project names.'),
  20. ),
  21. 'aliases' => array('dre'),
  22. );
  23. $items['fn-hook'] = array(
  24. 'description' => 'List implementations of a given hook and explore source of specified one.',
  25. 'arguments' => array(
  26. 'hook' => 'The name of the hook to explore.'
  27. ),
  28. 'aliases' => array('fnh', 'hook'),
  29. );
  30. $items['fn-view'] = array(
  31. 'description' => 'Show the source of specified function or method.',
  32. 'arguments' => array(
  33. 'function' => 'The name of the function or method to view.',
  34. ),
  35. 'options' => array(
  36. 'pipe' => 'Output just the filename of the function',
  37. 'format' => 'Specify how the filename should be printed. Available placeholders are !startline, !endline and !file',
  38. ),
  39. 'examples' => array(
  40. 'fn-view drupal_set_breadcrumb' => 'View the source code for function "drupal_set_breadcrumb"',
  41. 'vi `drush --pipe fn-view user_access --format=\'+!startline !file\'`' => 'Edit the file that contains the function "user_access"',
  42. 'fn-view NodeController::load' => 'View the source code for method load in the class NodeController'
  43. ),
  44. 'aliases' => array('fnv'),
  45. );
  46. $items['devel-token'] = array(
  47. 'description' => dt('List available tokens'),
  48. 'aliases' => array('token'),
  49. 'core' => array(7), // Remove once 3.0 is released.
  50. );
  51. return $items;
  52. }
  53. /**
  54. * A command callback. This is faster than 3 separate bootstraps.
  55. */
  56. function drush_devel_reinstall() {
  57. $projects = func_get_args();
  58. $args = array_merge(array('pm-disable'), $projects);
  59. call_user_func_array('drush_invoke', $args);
  60. $args = array_merge(array('pm-uninstall'), $projects);
  61. call_user_func_array('drush_invoke', $args);
  62. $args = array_merge(array('pm-enable'), $projects);
  63. call_user_func_array('drush_invoke', $args);
  64. }
  65. /**
  66. * A command callback.
  67. */
  68. function drush_devel_download() {
  69. $args = func_get_args();
  70. if (isset($args[0])) {
  71. $path = $args[0];
  72. }
  73. else {
  74. $path = drush_get_context('DRUSH_DRUPAL_ROOT');
  75. if (module_exists('libraries')) {
  76. $path .= '/' . libraries_get_path('FirePHPCore') . '/FirePHPCore';
  77. }
  78. else {
  79. $path .= '/' . drupal_get_path('module', 'devel') . '/FirePHPCore';
  80. }
  81. }
  82. if (is_dir($path)) {
  83. drush_log('FirePHP already present. No download required.', 'ok');
  84. }
  85. elseif (drush_shell_exec('svn export http://firephp.googlecode.com/svn/branches/Library-FirePHPCore-0.3 ' . $path)) {
  86. drush_log(dt('FirePHP has been exported via svn to @path.', array('@path' => $path)), 'success');
  87. }
  88. else {
  89. drush_log(dt('Drush was unable to export FirePHP to @path.', array('@path' => $path)), 'warning');
  90. }
  91. }
  92. /**
  93. * Implements drush_MODULE_post_COMMAND().
  94. */
  95. function drush_devel_post_pm_enable() {
  96. $extensions = func_get_args();
  97. // Deal with comma delimited extension list.
  98. if (strpos($extensions[0], ',') !== FALSE) {
  99. $extensions = explode(',', $extensions[0]);
  100. }
  101. if (in_array('devel', $extensions) && !drush_get_option('skip')) {
  102. drush_devel_download();
  103. }
  104. }
  105. /**
  106. * Command handler. Show hook implementations.
  107. */
  108. function drush_devel_fn_hook($hook) {
  109. // Get implementations in the .install files as well.
  110. include_once './includes/install.inc';
  111. drupal_load_updates();
  112. if ($hook_implementations = module_implements($hook)) {
  113. if ($choice = drush_choice(array_combine($hook_implementations, $hook_implementations), 'Enter the number of the hook implementation you wish to view.')) {
  114. return drush_devel_fn_view($choice . "_$hook");
  115. }
  116. }
  117. else {
  118. drush_log(dt('No implementations.'), 'ok');
  119. }
  120. }
  121. /**
  122. * Command handler. Show source code of specified function or method.
  123. */
  124. function drush_devel_fn_view($function_name) {
  125. // Get implementations in the .install files as well.
  126. include_once './includes/install.inc';
  127. drupal_load_updates();
  128. if (strpos($function_name, '::') === FALSE) {
  129. if (!function_exists($function_name)) {
  130. return drush_set_error(dt('Function not found'));
  131. }
  132. $reflect = new ReflectionFunction($function_name);
  133. }
  134. else {
  135. list($class, $method) = explode('::', $function_name);
  136. if (!method_exists($class, $method)) {
  137. return drush_set_error(dt('Method not found'));
  138. }
  139. $reflect = new ReflectionMethod($class, $method);
  140. }
  141. $func_info = array('!file' => $reflect->getFileName(), '!startline' => $reflect->getStartLine(), '!endline' => $reflect->getEndLine());
  142. $format = drush_get_option('format', '!file');
  143. drush_print_pipe(dt($format, $func_info));
  144. drush_print(dt("// file: !file, lines !startline-!endline", $func_info));
  145. _drush_devel_print_function($reflect->getFileName(), $reflect->getStartLine(), $reflect->getEndLine());
  146. }
  147. /**
  148. * Command callback. List available tokens.
  149. */
  150. function drush_devel_token() {
  151. $rows[] = array(dt('Group'), dt('Token'), dt('Name'));
  152. $all = token_info();
  153. foreach ($all['tokens'] as $group => $tokens) {
  154. foreach ($tokens as $key => $token) {
  155. $rows[] = array($group, $key, $token['name']);
  156. }
  157. }
  158. drush_print_table($rows, TRUE);
  159. }
  160. /**
  161. * Print the specified function, including any
  162. * doxygen-style comments that come before it.
  163. */
  164. function _drush_devel_print_function($file, $start_line, $end_line) {
  165. $line_num = 0;
  166. $doxygen = NULL;
  167. $fp = fopen( $file, 'r' );
  168. while (!feof($fp) && ($line_num < ($start_line - 1))) {
  169. $line = fgets($fp);
  170. ++$line_num;
  171. if (substr($line,0,3) == '/**') {
  172. $doxygen = $line;
  173. }
  174. elseif (isset($doxygen)) {
  175. $doxygen .= $line;
  176. if ($line_num + 1 == $start_line) {
  177. drush_print(rtrim($doxygen));
  178. }
  179. if (strstr($line, '*/') !== FALSE) {
  180. $doxygen = NULL;
  181. }
  182. }
  183. }
  184. while (!feof($fp) && ($line_num < $end_line)) {
  185. $line = fgets($fp);
  186. ++$line_num;
  187. drush_print(rtrim($line));
  188. }
  189. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.