You are here

function asaf_get_needed_files_list in Asaf (ajax submit for any form) 7

Same name and namespace in other branches
  1. 8 asaf.module \asaf_get_needed_files_list()
1 call to asaf_get_needed_files_list()
AsafUnitTests::testNeededFilesList in tests/asaf.test

File

./asaf.module, line 416

Code

function asaf_get_needed_files_list(array $files) {
  $list = array();
  foreach ($files as $file) {
    if (is_array($file) && isset($file['module']) || is_string($file) && file_exists($file)) {
      $list[] = $file;
    }
    elseif (is_string($file) && module_exists($file)) {

      // Loading all includes of the module
      $path = drupal_get_path('module', $file);
      $destination = DRUPAL_ROOT . '/' . $path;
      $list[] = $path . '/' . $file . '.module';
      $pattern = '/.inc$/';
      $matches = array_keys(file_scan_directory($destination, $pattern));
      if (is_array($matches)) {
        foreach ($matches as $inc) {
          $parts = explode(DRUPAL_ROOT . '/', $inc);
          if (isset($parts[1]) && $parts[1]) {
            $list[] = $parts[1];
          }
        }
      }
    }
  }
  return $list;
}