PluginManager

Extends\CApplicationComponent

Factory for limesurvey plugin objects.

package

Default

Methods

dispatchEvent

dispatchEvent(): mixed

: void

Response

mixed

This function dispatches an event to all registered plugins.

dispatchEvent(\LimeSurvey\PluginManager\PluginEvent $event,string|array $target = array()): \LimeSurvey\PluginManager\PluginEvent

Arguments

$event

\LimeSurvey\PluginManager\PluginEvent

Object holding all event properties

$target

string|array

Optional name of plugin to fire the event on

Response

\LimeSurvey\PluginManager\PluginEvent

Return the list of core plugins allowed to be loaded.

getAllowedCorePluginList(): array<mixed,string>

That is, all core plugins not in the black list.

Response

array<mixed,string>

This function returns an API object, exposing an API to each plugin.

getAPI(): \LimeSurvey\PluginManager\LimesurveyApi

In the current case this is the LimeSurvey API.

Response

\LimeSurvey\PluginManager\LimesurveyApi

Return the core plugin list No way to update by php or DB

getCorePluginList(): array<mixed,string>
static

Response

array<mixed,string>

Return a list of installed plugins, but only if the files are still there

getInstalledPlugins(): array
deprecated

unused in 5.3.8 This prevents errors when a plugin was installed but the files were removed from the server.

Response

array

Get plugin description.

getPluginDescription(string $class,\ExtensionConfig $extensionConfig = null): string

First look in config.xml, then in plugin class.

todo

Localization.

Arguments

$class

string

$extensionConfig

\ExtensionConfig

Response

string

getPluginFolder

getPluginFolder(\ExtensionConfig $config,string $pluginType)

Arguments

$pluginType

string

User, core or upload

Gets the description of a plugin. The description is accessed via a static function inside the plugin file.

getPluginInfo(string $pluginClass, $pluginDir = null): array|null
todo

Read config.xml instead.

Arguments

$pluginClass

string

The classname of the plugin

$pluginDir

Response

array|null

Get plugin name.

getPluginName(string $class,\ExtensionConfig $extensionConfig = null): string

First look in config.xml, then in plugin class.

todo

Localization.

Arguments

$class

string

$extensionConfig

\ExtensionConfig

Response

string

Returns the storage instance of type $storageClass.

getStore(string $storageClass): mixed

If needed initializes the storage object.

Arguments

$storageClass

string

Response

mixed

Creates the plugin manager. Loads all active plugins.

init(): void

If $plugin->save() is used in this method, it can lead to an infinite event loop, since beforeSave tries to get the PluginManager, which executes init() again.

Install a plugin given a plugin configuration and plugin type (core or user).

installPlugin(\ExtensionConfig $extensionConfig,string $pluginType): array

Arguments

$extensionConfig

\ExtensionConfig

$pluginType

string

'user' or 'core', depending on location of folder.

Response

array

[boolean $result, string $errorMessage]

installUploadedPlugin

installUploadedPlugin(string $destdir): array

Arguments

$destdir

string

Response

array

[boolean $result, string $errorMessage]

Return the status of plugin (true/active or false/desactive)

isPluginActive( $sPluginName): boolean

Arguments

$sPluginName

Response

boolean

Returns true if the plugin name is whitelisted or the whitelist is disabled.

isWhitelisted(string $pluginName): boolean

Arguments

$pluginName

string

Response

boolean

Load ALL plugins, active and non-active

loadAllPlugins(): void

Returns the instantiated plugin

loadPlugin(string $pluginName,integer $id = null,boolean $init = true): \LimeSurvey\PluginManager\iPlugin|null

Arguments

$pluginName

string

$id

integer

Identifier used for identifying a specific plugin instance.

$init

boolean

launch init function (if exist) If ommitted will return the first instantiated plugin with the given name.

Response

\LimeSurvey\PluginManager\iPlugin|null

The plugin or null when missing

Handles loading all active plugins

loadPlugins()

Possible improvement would be to load them for a specific context. For instance 'survey' for runtime or 'admin' for backend. This needs some thinking before implementing.

Get a list of question objects and load some information about them.

loadQuestionObjects( $forceReload = false)

This registers the question object classes with Yii.

Arguments

$forceReload

Read all plugin config files and updates information in database if plugin version differs.

readConfigFiles(): void

Scans the plugin directory for plugins.

scanPlugins(boolean $includeInstalledPlugins = false): array

This function is not efficient so should only be used in the admin interface that specifically deals with enabling / disabling plugins.

todo

Factor out

Arguments

$includeInstalledPlugins

boolean

If set, also return plugins even if already installed in database.

Response

array

Registers a plugin to be notified on some event.

subscribe(\LimeSurvey\PluginManager\iPlugin $plugin,string $event,string $function = null)

Arguments

$plugin

\LimeSurvey\PluginManager\iPlugin

Reference to the plugin.

$event

string

Name of the event.

$function

string

Optional function of the plugin to be called.

Unsubscribes a plugin from an event.

unsubscribe(\LimeSurvey\PluginManager\iPlugin $plugin,string $event)

Arguments

$plugin

\LimeSurvey\PluginManager\iPlugin

Reference to the plugin being unsubscribed.

$event

string

Name of the event. Use '*', to unsubscribe all events for the plugin.

Properties

Object containing any API that the plugins can use.

api :mixed
var

The class name of the API class to load, or

Type(s)

mixed

Array mapping guids to question object class names.

guidToQuestion :array
var

Type(s)

array

plugins

plugins :array
var

Type(s)

array

pluginDirs

pluginDirs :array
var

Type(s)

array

stores

stores :array
var

Type(s)

array

array> Array with string key to tuple value like 'eventName' => array($plugin, $method)

subscriptions :\LimeSurvey\PluginManager\array<string,
var

array> Array with string key to tuple value like 'eventName' => array($plugin, $method)

Type(s)

\LimeSurvey\PluginManager\array

Created at init.

shutdownObject :\LimeSurvey\PluginManager\PluginManagerShutdownFunction

Used to deal with syntax errors etc in plugins during load.

var

Type(s)

\LimeSurvey\PluginManager\PluginManagerShutdownFunction