mysite_get_includes

Definition

mysite_get_includes($type = NULL, $name = NULL)
mysite.module, line 3354

Description

Return the valid include files for a given include type. This function is used to check which files to load when mysite_load_includes() is called. It checks to see that the include files are actually located inside the appropriate 'mysite/plugins' directory.

see file_scan_directory()

Parameters

$type The type of include to return (a string). If NULL, all will be returned.

$name The filename of a specific include to return (but not it's file extension).

Return value

File results are returned according to file_scan_directory() with key of 'name'.

Code

function mysite_get_includes($type = NULL, $name = NULL) {
  if (is_null($type)) {
    drupal_set_message(t('The $type was not set'), 'error');
    return;
  }
  $dir = drupal_get_path('module', 'mysite') ."/plugins/$type";
  $mask = mysite_get_mask($type);
  if (!is_null($name)) {
    $mask = $name . $mask;
  }
  $includes = file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $callback = 0, $recurse = FALSE, $key = 'name', $min_depth = 0, $depth = 0);
  if (empty($includes)) {
    mysite_plugin_failure($type, $name);
  }
  return $includes;
}