Omeka_Plugin_Loader

Package: Plugin\Loader

class Omeka_Plugin_Loader

Loads plugins for any given request.

This will iterate through the plugins root directory and load all plugin.php files by require()’ing them.

property _broker

protected Omeka_Plugin_Broker

Plugin broker object.

property _iniReader

protected Omeka_Plugin_Ini

Plugin INI reader object.

property _mvc

protected Omeka_Plugin_Mvc

Plugin MVC object.

property _basePath

protected string

Plugins directory.

property _plugins

protected array

An array of all plugins (installed or not) that are currently located in the plugins/ directory.

__construct(Omeka_Plugin_Broker $broker, Omeka_Plugin_Ini $iniReader, Omeka_Plugin_Mvc $mvc, $pluginsBaseDir)
Parameters:
loadPlugins($plugins, $force = false)

Load a list of plugins.

Parameters:
  • $plugins (array) – List of Plugin records to load.
  • $force (bool) – If true, throws exceptions for plugins that cannot be loaded for some reason.
registerPlugin(Plugin $plugin)

Register a plugin so that it can be accessed by other plugins (if necessary) during the load process.

There should only be a single instance of a plugin per directory name. Registering a plugin more than once, i.e. loading a plugin again after the first time failed, will not cause a problem as long as the same instance was registered.

Parameters:
  • $plugin (Plugin) – Record of plugin to register.
isRegistered(Plugin $plugin)

Return whether a plugin is registered or not.

Parameters:
Returns:

bool Whether the plugin is registered or not.

load(Plugin $plugin, $force = false, $pluginsWaitingToLoad = array())

Load a plugin (and make sure the plugin API is available).

To be loaded, the plugin must be installed, active, and not have a newer version. If loaded, the plugin will attempt to first load all plugins, both required and optional, that the plugin uses. However, it will not load a plugin that it uses if that plugin is not installed and activated.

Parameters:
  • $plugin (Plugin) –
  • $force (bool) – If true, throws exceptions if a plugin can’t be loaded.
  • $pluginsWaitingToLoad (array) – Plugins waiting to be loaded
_canLoad($plugin, $force)

Determine whether or not a plugin can be loaded. To be loaded, it must meet the following criteria: - Has a plugin.php file. - Is installed. - Is active. - Meets the minimum required version of Omeka (in plugin.ini). - Is not already loaded. - Does not have a new version available.

Parameters:
  • $plugin (Plugin) – Plugin to test.
  • $force (bool) – If true, throw an exception if the plugin can’t be loaded.
Returns:

bool

hasPluginBootstrap($pluginDirName)

Check whether a plugin has a bootstrap file.

Parameters:
  • $pluginDirName (string|Plugin) –
Returns:

bool

getPluginClassName($pluginDirName)

Return the valid plugin class name.

Parameters:
  • $pluginDirName (string) –
Returns:

string

getPluginFilePath($pluginDirName)

Return the path to the plugin.php file.

Parameters:
  • $pluginDirName (string) –
Returns:

string

getPluginClassFilePath($pluginDirName)

Return the path to the plugin class file.

Parameters:
  • $pluginDirName (string) –
Returns:

string

getPlugins()

Return a list of all the plugins that have been loaded (or attempted to be loaded) thus far.

Returns:array List of Plugin objects.
getPlugin($directoryName)

Get a plugin object by name (plugin subdirectory name).

Parameters:
  • $directoryName (string) – Plugin name.
Returns:

Plugin|null

_loadPluginBootstrap(Plugin $plugin)

Loads the plugin bootstrap file for a plugin.

Parameters: