You are here

function linkit_get_plugin_handler in Linkit 7.2

Get the plugin handler for a given plugin.

3 calls to linkit_get_plugin_handler()
linkit_profiles_export_ui_form in plugins/export_ui/linkit_profiles.inc
Generate a profile form.
_linkit_autocomplete_search in ./linkit.module
Perform internal autocomplete search.
_linkit_build_plugin_form_fields in plugins/export_ui/linkit_profiles.inc
Append plugin form element to the setttings form.

File

./linkit.module, line 940
Main file for linkit module.

Code

function linkit_get_plugin_handler($plugin, $profile = NULL) {
  $object_cache = drupal_static(__FUNCTION__);
  $identifier = $plugin['name'];
  if (!isset($object_cache[$identifier])) {
    ctools_include('plugins');

    // Try load the default handler.
    $class = ctools_plugin_get_class($plugin, 'handler');
    if (class_exists($class)) {
      $object_cache[$identifier] = new $class($plugin, $profile);
    }
    else {
      $object_cache[$identifier] = new LinkitPluginBroken($plugin, $profile);

      // The default handler class does not seems to exists, lets try the
      // entity fallback handler if we have any.
      if (isset($plugin['entity fallback handler'])) {
        $fallback_class = ctools_plugin_get_class($plugin, 'entity fallback handler');
        if (class_exists($fallback_class)) {
          $object_cache[$identifier] = new $fallback_class($plugin, $profile);
        }
      }
    }
  }
  return $object_cache[$identifier];
}