You are here

function ctools_passthrough in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/utility.inc \ctools_passthrough()

Provide a hook passthrough to included files.

To organize things neatly, each CTools tool gets its own toolname.$type.inc file. If it exists, it's loaded and ctools_$tool_$type() is executed. To save time we pass the $items array in so we don't need to do array addition. It modifies the array by reference and doesn't need to return it.

3 calls to ctools_passthrough()
ctools_cron in ./ctools.module
Implementation of hook_cron. Clean up old caches.
ctools_menu in ./ctools.module
Implementation of hook_menu().
ctools_theme in ./ctools.module
Implementation of hook_theme().

File

includes/utility.inc, line 20
Contains general utility functions for CTools that do not need to be in the module file.

Code

function ctools_passthrough($module, $type, &$items) {
  $files = drupal_system_listing('.' . $type . '.inc$', drupal_get_path('module', $module) . '/includes', 'name', 0);
  foreach ($files as $file) {
    require_once './' . $file->filename;
    list($tool) = explode('.', $file->name, 2);
    $function = $module . '_' . str_replace('-', '_', $tool) . '_' . $type;
    if (function_exists($function)) {
      $function($items);
    }
  }
}