You are here

function defaultcontent_get_alter_plugins in Default Content 7

Same name and namespace in other branches
  1. 7.2 defaultcontent.module \defaultcontent_get_alter_plugins()

Return all alter plugins

Parameters

$use: A plugin key that can be used for sorting "$use weight" will be used to sort the plugins

3 calls to defaultcontent_get_alter_plugins()
defaultcontent_export_node_process in ./defaultcontent.module
Produces an export object form a node object
defaultcontent_import_node in ./defaultcontent.module
This function takes a node object from hook_defaultcontents and insert it into the db TODO: need to do something fun with files TODO: need to do something fun with node refs
defaultcontent_import_sort in ./defaultcontent.module
use to sort component

File

./defaultcontent.module, line 415
Module file for the Default content module which allow export and import of default content in a Drupal site.

Code

function defaultcontent_get_alter_plugins($use = FALSE) {
  ctools_include('plugins');
  $plugins = ctools_get_plugins('defaultcontent', 'alter');

  // check if the plugin has a enabled callback if so make sure this plugin
  // is enabled
  foreach ($plugins as $id => $plugin) {
    $cb = isset($plugin['enabled callback']) ? $plugin['enabled callback'] : $plugin['name'] . '_enabled';
    if (function_exists($cb)) {
      if (!$cb()) {
        unset($plugins[$id]);
      }
    }
  }
  if ($use) {
    usort($plugins, function ($a, $b) use ($use) {
      $weight_key = $use . ' weight';
      return $a[$weight_key] - $b[$weight_key];
    });
  }
  return $plugins;
}