You are here

function _ctools_process_data in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/plugins.inc \_ctools_process_data()

Fill in default values and run hooks for data loaded for one or more plugins.

2 calls to _ctools_process_data()
ctools_plugin_process in includes/plugins.inc
Process a single hook implementation of a ctools plugin.
ctools_plugin_process_info in includes/plugins.inc
Process an info file for plugin information, rather than a hook.

File

includes/plugins.inc, line 710
Contains routines to organize and load plugins. It allows a special variation of the hook system so that plugins can be kept in separate .inc files, and can be either loaded all at once or loaded only when necessary.

Code

function _ctools_process_data($result, $plugin_type_info, $module, $path, $file) {

  // Fill in global defaults.
  foreach ($result as $name => $plugin) {
    $result[$name] += array(
      'module' => $module,
      'name' => $name,
      'path' => $path,
      'file' => $file,
      'plugin module' => $plugin_type_info['module'],
      'plugin type' => $plugin_type_info['type'],
    );

    // Fill in plugin-specific defaults, if they exist.
    if (!empty($plugin_type_info['defaults'])) {
      if (is_array($plugin_type_info['defaults'])) {
        $result[$name] += $plugin_type_info['defaults'];
      }
    }

    // Allow the plugin to be altered before processing.
    if (!empty($plugin_type_info['alterable']) && $plugin_type_info['alterable']) {
      drupal_alter('ctools_plugin_pre', $result[$name], $plugin_type_info);
    }

    // Allow the plugin owner to do additional processing.
    if (!empty($plugin_type_info['process']) && ($function = ctools_plugin_get_function($plugin_type_info, 'process'))) {
      $function($result[$name], $plugin_type_info);
    }

    // Allow the plugin to be altered after processing.
    if (!empty($plugin_type_info['alterable']) && $plugin_type_info['alterable']) {
      drupal_alter('ctools_plugin_post', $result[$name], $plugin_type_info);
    }
  }
  return $result;
}