You are here

function media_load_all_exports in D7 Media 7.2

Same name and namespace in other branches
  1. 7.4 media.module \media_load_all_exports()
  2. 7.3 media.module \media_load_all_exports()

Fetches an array of exportables from files.

Parameters

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

string $directory: The subdirectory in the custom module.

string $extension: The file extension.

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

Return value

array Array of $name objects.

1 call to media_load_all_exports()
media_views_default_views in ./media.module
Implements hook_views_default_views().

File

./media.module, line 1384
Media API

Code

function media_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;
}