You are here

public function Sweaver::get_plugin in Sweaver 7

Same name and namespace in other branches
  1. 6 sweaver.inc \Sweaver::get_plugin()

get_plugin. Gets a sweaver plugin, and instantiates it if not loaded yet.

File

./sweaver.inc, line 122
Class Sweaver.

Class

Sweaver
@file Class Sweaver.

Code

public function get_plugin($name, $enabled = TRUE) {
  if (!isset($this->plugins_registry[$name])) {
    drupal_set_message(t('No configuration found for @name in the plugin registry', array(
      '@name' => $name,
    )));
  }
  if (!isset($this->plugins[$name])) {
    module_load_include('inc', 'sweaver', 'sweaver_plugin');
    $check = $enabled ? isset($this->plugins_registry_enabled[$name]) : TRUE;
    if ($check && ($class = ctools_plugin_get_class($this->plugins_registry[$name], 'handler'))) {

      // Check that class exists until CTools & registry issues are resolved.
      if (class_exists($class)) {
        $this->plugins[$name] = new $class($this->plugins_registry[$name]);
      }
    }
    else {
      $this->plugins[$name] = FALSE;
    }
  }
  return $this->plugins[$name];
}