You are here

public function Sweaver::register_plugins_configuration in Sweaver 7

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

register_plugins_configuration. Registers an array of plugin configuration data to Sweaver.

1 call to Sweaver::register_plugins_configuration()
Sweaver::__construct in ./sweaver.inc
Constructor. Private constructor to make sure this is never instantiated by the constructor.

File

./sweaver.inc, line 51
Class Sweaver.

Class

Sweaver
@file Class Sweaver.

Code

public function register_plugins_configuration() {

  // Load the required plugins of ctools and the sweaver base class.
  ctools_include('plugins');

  // Check if the configuration was cached or not.
  if ($plugins_cache = cache_get('sweaver_plugins')) {
    $this->plugins_registry = $plugins_cache->data['sweaver_plugins'];
    $this->plugins_registry_enabled = $plugins_cache->data['sweaver_plugins_enabled'];
  }
  else {
    $this->plugins_registry = ctools_get_plugins('sweaver', 'plugins');

    // Build enabled plugins.
    foreach ($this->plugins_registry as $key => $plugin) {
      $this->plugins_registry[$key]['enabled'] = 0;
      if (variable_get('sweaver_plugin_status_' . $key, FALSE)) {
        $this->plugins_registry[$key]['enabled'] = 1;
        $this->plugins_registry_enabled[$key] = $this->plugins_registry[$key];
      }
    }

    // Cache the plugins ourselves too.
    $sweaver_plugins['sweaver_plugins'] = $this->plugins_registry;
    $sweaver_plugins['sweaver_plugins_enabled'] = $this->plugins_registry_enabled;
    cache_set('sweaver_plugins', $sweaver_plugins);
  }
  $this->configured = TRUE;
}