Browse Source

Issue #1565324 by fgm: Support multiple source directories in Class Grapher.

fgm 12 years ago
parent
commit
fbc349ecc3
2 changed files with 20 additions and 17 deletions
  1. 16 15
      OSInet/Class_Grapher/Graph.php
  2. 4 2
      apps/class_grapher/classgrapher.drush.inc

+ 16 - 15
OSInet/Class_Grapher/Graph.php

@@ -56,7 +56,7 @@ class Graph {
    * TODO support base as a file instead of a directory.
    *
    * @param string $base
-   *   A starting path for file lookup.
+   *   A starting path or array of paths for file lookup.
    * @param array $blackList
    *   An array of file names to reject, whatever their path.
    * @param string $pattern
@@ -67,24 +67,25 @@ class Graph {
    */
   public function getFiles($base, $blackList = array(),
     $pattern = '/.*\.(inc|module|php)$/') {
-
-    $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($base,
-      \FilesystemIterator::KEY_AS_PATHNAME  | \FilesystemIterator::SKIP_DOTS));
     $files = array();
-    while ($dir->valid()) {
-      $name = $dir->key();
-      if (preg_match($pattern, $name) && !in_array(basename($name), $blackList)) {
-        $files[] = $name;
-      }
-      elseif ($this->logger->debugLevel >= LOG_INFO) {
-        if (in_array(basename($name), $blackList)) {
-          $this->debug("$name blacklisted.\n", LOG_INFO);
+    foreach ($base as $start) {
+      $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($start,
+        \FilesystemIterator::KEY_AS_PATHNAME  | \FilesystemIterator::SKIP_DOTS));
+      while ($dir->valid()) {
+        $name = $dir->key();
+        if (preg_match($pattern, $name) && !in_array(basename($name), $blackList)) {
+          $files[] = $name;
         }
-        else {
-          $this->debug("$name does not match source paths.\n", LOG_DEBUG);
+        elseif ($this->logger->debugLevel >= LOG_INFO) {
+          if (in_array(basename($name), $blackList)) {
+            $this->debug("$name blacklisted.\n", LOG_INFO);
+          }
+          else {
+            $this->debug("$name does not match source paths.\n", LOG_DEBUG);
+          }
         }
+        $dir->next();
       }
-      $dir->next();
     }
 
     $files = array_unique($files);

+ 4 - 2
apps/class_grapher/classgrapher.drush.inc

@@ -28,7 +28,7 @@ function classgrapher_drush_command() {
     'core' => array('7'),
     'drupal dependencies' => array('libraries'),
     'arguments' => array(
-      'base' => 'The base directory below which to parse source files.',
+      'base' => 'A space-separated list of base directories below which to parse source files.',
     ),
     'options' => array(
       'cgdebug' => array(
@@ -114,13 +114,15 @@ function drush_classgrapher_classgraph_validate() {
 /**
  * Command callback for classgraph.
  */
-function drush_classgrapher_classgraph($base) {
+function drush_classgrapher_classgraph() {
   $optionDefaults = array(
     'imager' => 'dot',
     'debug' => WATCHDOG_INFO,
     'format' => 'svg',
   );
 
+  $base = func_get_args();
+
   foreach ($optionDefaults as $name => $default) {
     $$name = drush_get_option("cg$name", $default);
   }