class plugin_support

internal  
 

Unified wrapper for Moodle plugin APIs.

Provides stable access to plugin metadata across Moodle versions, encapsulating differences between:

  • core_component vs \core\component
  • core_plugin_manager vs plugin_manager

Returns DTOs instead of core plugininfo objects to ensure stability and avoid exposing Moodle internals directly.

Methods

__construct()

Initializes the plugin manager and component class based on Moodle version.

array
get_plugin_types()

Retrieves all plugin types installed in Moodle.

array
get_plugins_of_type(string $type)

Retrieves list of plugins of a specific type.

bool
plugin_exists(string $type, string $plugin)

Checks if a plugin exists on disk.

string
get_plugin_directory(string $type, string $plugin)

Retrieves the plugin directory path on disk.

string
plugin_displayname(string $type, string $plugin)

Retrieves the display name of a plugin.

get_plugin_info(string $type, string $plugin)

Retrieves a DTO containing complete plugin metadata.

array
get_all_plugins()

Retrieves all plugins as DTOs, grouped by type.

array
get_enabled_plugins()

Retrieves all enabled plugins as DTOs.

bool
is_enabled(string $type, string $plugin)

Checks if a specific plugin is enabled.

Details

at line 51
__construct()

Initializes the plugin manager and component class based on Moodle version.

at line 68
array get_plugin_types()

Retrieves all plugin types installed in Moodle.

Return Value

array

Map of plugin type to directory

at line 80
array get_plugins_of_type(string $type)

Retrieves list of plugins of a specific type.

Parameters

string $type

The plugin type (e.g., 'mod', 'local').

Return Value

array

Map of plugin name to directory

at line 93
bool plugin_exists(string $type, string $plugin)

Checks if a plugin exists on disk.

Parameters

string $type

Plugin type

string $plugin

Plugin name

Return Value

bool

True if plugin exists, false otherwise

at line 108
string get_plugin_directory(string $type, string $plugin)

Retrieves the plugin directory path on disk.

Parameters

string $type

Plugin type

string $plugin

Plugin name

Return Value

string

the plugin directory path

Exceptions

moodle_exception

at line 127
string plugin_displayname(string $type, string $plugin)

Retrieves the display name of a plugin.

Parameters

string $type

Plugin type

string $plugin

Plugin name

Return Value

string

the plugin display name

at line 142
plugin_dto get_plugin_info(string $type, string $plugin)

Retrieves a DTO containing complete plugin metadata.

Parameters

string $type

Plugin type

string $plugin

Plugin name

Return Value

plugin_dto

the plugin metadata DTO

Exceptions

moodle_exception

at line 188
array get_all_plugins()

Retrieves all plugins as DTOs, grouped by type.

Return Value

array

grouped list of plugin DTOs

at line 208
array get_enabled_plugins()

Retrieves all enabled plugins as DTOs.

Return Value

array

list of enabled plugin DTOs

at line 233
bool is_enabled(string $type, string $plugin)

Checks if a specific plugin is enabled.

Parameters

string $type

Plugin type

string $plugin

Plugin name

Return Value

bool

True if enabled, false otherwise