Class SloodlePluginManager

Description

A class to load SLOODLE plugins, and provide a means to access them.

Located in /lib/plugins.php (line 25)


	
			
Variable Summary
 object $_session
Method Summary
 SloodlePluginManager SloodlePluginManager (object &$_session)
 object|bool get_plugin (string $name, [bool $forcenew = false])
 array get_plugin_names ([string $type = 'SloodlePluginBase'])
 bool load_plugins (string $folder)
Variables
array $plugin_cache = array() (line 44)

Plugin instance cache.

Stores the plugins which have already been created, to prevent new ones being instantiated unnecessarily. Is an associative array of plugin names to plugin objects.

  • access: protected
object $_session = null (line 35)

Internal only - reference to the containing SloodleSession object.

Note: always check that it is not null before use!

  • access: protected
Methods
Constructor SloodlePluginManager (line 54)

Class constructor.

  • access: public
SloodlePluginManager SloodlePluginManager (object &$_session)
  • object &$_session: Reference to the containing SloodleSession object, if available.
get_plugin (line 128)

Gets an instance of the specified plugin type.

This only works if the plugin has been loaded, and if it is derived from SloodlePluginBase.

  • return: An object descended from SloodlePluginBase if successful, or false on failure.
object|bool get_plugin (string $name, [bool $forcenew = false])
  • string $name: Name of the plugin type to get. If it does not start with "SloodlePlugin", then that is added to the start.
  • bool $forcenew: If false (default) then a cached instance of the plugin will be returned. Set this to true to force the manager to create a new plugin instance.
get_plugin_names (line 96)

Gets an array of the names of all SLOODLE plugins derived from the specified type.

By default, this gets all plugins. Specify a different base class to get others. NOTE: this will search all plugins loaded by all plugin managers in the current PHP script. (There is no way to tell which manager loaded which plugins.) Plugin names correspond to class names, with the 'SloodlePlugin' prefix.

  • return: Numeric array of plugin names. These names correspond to class names.
array get_plugin_names ([string $type = 'SloodlePluginBase'])
  • string $type: Name of a plugin base class.
load_plugins (line 64)

Loads all available plugins from the specified folder.

  • return: True if successful, or false if it fails. (It will only report failure if the folder does not exist, or there is an error accessing it.)
bool load_plugins (string $folder)
  • string $folder: Name of the folder to load plugins from. This is a sub-folder of the 'sloodle/plugin' folder. It will only load files which are directly contained inside it.

Documentation generated on Fri, 17 Jul 2009 11:02:22 +0100 by phpDocumentor 1.4.0