You are here

function workbench_load_all_exports in Workbench 7

Fetches an array of exportables from files.

Parameters

$module: The module invoking this request. (Can be called by other modules.)

$directory: The subdirectory in the custom module.

$extension: The file extension.

$name: The name of the variable found in each file. Defaults to the same as $extension.

Return value

Array of $name objects.

1 call to workbench_load_all_exports()
workbench_views_default_views in ./workbench.module
Implements hook_views_default_views().

File

./workbench.module, line 154
Workbench module file for editorial workspaces.

Code

function workbench_load_all_exports($module, $directory, $extension, $name = NULL) {
  if (!$name) {
    $name = $extension;
  }
  $return = array();

  // Find all the files in the directory with the correct extension.
  $files = file_scan_directory(drupal_get_path('module', $module) . "/{$directory}", "/\\.{$extension}\$/");
  foreach ($files as $path => $file) {
    require $path;
    if (isset(${$name})) {
      $return[${$name}->name] = ${$name};
    }
  }
  return $return;
}