info.pm.inc

  1. 8.0.x commands/pm/info.pm.inc
  2. 6.x commands/pm/info.pm.inc
  3. 7.x commands/pm/info.pm.inc
  4. 5.x commands/pm/info.pm.inc
  5. master commands/pm/info.pm.inc

pm-info command implementation.

Functions

Namesort descending Description
drush_pm_info Command callback. Show detailed info for one or more extensions.
_drush_pm_info_extension Return an array with general info of an extension.
_drush_pm_info_format_table_data Output format formatter-filter callback.
_drush_pm_info_module Return an array with info of a module.
_drush_pm_info_theme Return an array with info of a theme.

File

commands/pm/info.pm.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * pm-info command implementation.
  5. */
  6. use Drush\Log\LogLevel;
  7. /**
  8. * Command callback. Show detailed info for one or more extensions.
  9. */
  10. function drush_pm_info() {
  11. $result = array();
  12. $args = pm_parse_arguments(func_get_args());
  13. $extension_info = drush_get_extensions(FALSE);
  14. _drush_pm_expand_extensions($args, $extension_info);
  15. // If no extensions are provided, show all.
  16. if (count($args) == 0) {
  17. $args = array_keys($extension_info);
  18. }
  19. foreach ($args as $extension) {
  20. if (isset($extension_info[$extension])) {
  21. $info = $extension_info[$extension];
  22. }
  23. else {
  24. drush_log(dt('!extension was not found.', array('!extension' => $extension)), LogLevel::WARNING);
  25. continue;
  26. }
  27. if (drush_extension_get_type($info) == 'module') {
  28. $data = _drush_pm_info_module($info);
  29. }
  30. else {
  31. $data = _drush_pm_info_theme($info);
  32. }
  33. $result[$extension] = $data;
  34. }
  35. return $result;
  36. }
  37. /**
  38. * Output format formatter-filter callback.
  39. *
  40. * @see drush_parse_command()
  41. * @see drush_outputformat
  42. */
  43. function _drush_pm_info_format_table_data($data) {
  44. $result = array();
  45. foreach ($data as $extension => $info) {
  46. foreach($info as $key => $value) {
  47. if (is_array($value)) {
  48. if (empty($value)) {
  49. $value = 'none';
  50. }
  51. else {
  52. $value = implode(', ', $value);
  53. }
  54. }
  55. $result[$extension][$key] = $value;
  56. }
  57. }
  58. return $result;
  59. }
  60. /**
  61. * Return an array with general info of an extension.
  62. */
  63. function _drush_pm_info_extension($info) {
  64. $data['extension'] = drush_extension_get_name($info);
  65. $data['project'] = isset($info->info['project'])?$info->info['project']:dt('Unknown');
  66. $data['type'] = drush_extension_get_type($info);
  67. $data['title'] = $info->info['name'];
  68. $data['config'] = isset($info->info['configure']) ? $info->info['configure'] : dt('None');
  69. $data['description'] = $info->info['description'];
  70. $data['version'] = $info->info['version'];
  71. $data['date'] = isset($info->info['datestamp']) ? format_date($info->info['datestamp'], 'custom', 'Y-m-d') : NULL;
  72. $data['package'] = $info->info['package'];
  73. $data['core'] = $info->info['core'];
  74. $data['php'] = $info->info['php'];
  75. $data['status'] = drush_get_extension_status($info);
  76. $data['path'] = drush_extension_get_path($info);
  77. return $data;
  78. }
  79. /**
  80. * Return an array with info of a module.
  81. */
  82. function _drush_pm_info_module($info) {
  83. $major_version = drush_drupal_major_version();
  84. $data = _drush_pm_info_extension($info);
  85. if ($info->schema_version > 0) {
  86. $schema_version = $info->schema_version;
  87. }
  88. elseif ($info->schema_version == -1) {
  89. $schema_version = "no schema installed";
  90. }
  91. else {
  92. $schema_version = "module has no schema";
  93. }
  94. $data['schema_version'] = $schema_version;
  95. if ($major_version == 7) {
  96. $data['files'] = $info->info['files'];
  97. }
  98. $data['requires'] = $info->info['dependencies'];
  99. if ($major_version == 6) {
  100. $requiredby = $info->info['dependents'];
  101. }
  102. else {
  103. $requiredby = array_keys($info->required_by);
  104. }
  105. $data['required_by'] = $requiredby;
  106. if ($info->status == 1) {
  107. $role = drush_role_get_class();
  108. $data['permissions'] = $role->getModulePerms(drush_extension_get_name($info));
  109. }
  110. return $data;
  111. }
  112. /**
  113. * Return an array with info of a theme.
  114. */
  115. function _drush_pm_info_theme($info) {
  116. $major_version = drush_drupal_major_version();
  117. $data = _drush_pm_info_extension($info);
  118. $data['core'] = $info->info['core'];
  119. $data['php'] = $info->info['php'];
  120. $data['engine'] = $info->info['engine'];
  121. $data['base_theme'] = isset($info->base_themes) ? implode($info->base_themes, ', ') : '';
  122. $regions = $info->info['regions'];
  123. $data['regions'] = $regions;
  124. $features = $info->info['features'];
  125. $data['features'] = $features;
  126. if (count($info->info['stylesheets']) > 0) {
  127. $data['stylesheets'] = '';
  128. foreach ($info->info['stylesheets'] as $media => $files) {
  129. $files = array_keys($files);
  130. $data['media '.$media] = $files;
  131. }
  132. }
  133. if (count($info->info['scripts']) > 0) {
  134. $scripts = array_keys($info->info['scripts']);
  135. $data['scripts'] = $scripts;
  136. }
  137. return $data;
  138. }