class config_support

internal  
 

Configuration utility wrapper for Moodle's config API.

This class centralizes access to get_config/set_config/unset_config for the plugin, providing a safe façade that catches exceptions and returns predictable values.

Constants

PLUGIN_NAME

Methods

static mixed
get(string|null $name = null)

Retrieves a configuration value for this plugin.

static mixed
get_config(string $plugin, string|null $name = null)

Retrieves configuration for any component or a single named key.

static bool
set_config(string $name, mixed $value, string $plugin = self::PLUGIN_NAME)

Sets a configuration value for a specific plugin or component.

static bool
unset_config(string $name, string $plugin = self::PLUGIN_NAME)

Unsets (removes) a configuration value.

static mixed
get_global(string $name)

Retrieves a value from the global Moodle configuration $CFG.

static stdClass
get_site()

Retrieves the site object ($SITE global).

static int
get_site_id()

Retrieves the SITEID constant value.

Details

at line 45
static mixed get(string|null $name = null)

Retrieves a configuration value for this plugin.

Parameters

string|null $name

the config key name

Return Value

mixed

the value if found, null if not set, or false on error

at line 68
static mixed get_config(string $plugin, string|null $name = null)

Retrieves configuration for any component or a single named key.

Parameters

string $plugin

The component name (e.g., 'local_middag' or 'core').

string|null $name

Optional key name. If null, returns stdClass with all settings for the component.

Return Value

mixed

stdClass for all settings, a single value, null if not set, or false on error

at line 88
static bool set_config(string $name, mixed $value, string $plugin = self::PLUGIN_NAME)

Sets a configuration value for a specific plugin or component.

Parameters

string $name

the config key name

mixed $value

The value to set. Will be converted to string by Moodle.

string $plugin

Component name, defaults to this plugin

Return Value

bool

True on success, false on failure

at line 107
static bool unset_config(string $name, string $plugin = self::PLUGIN_NAME)

Unsets (removes) a configuration value.

Parameters

string $name

the config key name to remove

string $plugin

Component name, defaults to this plugin

Return Value

bool

True on success, false on failure

at line 125
static mixed get_global(string $name)

Retrieves a value from the global Moodle configuration $CFG.

Parameters

string $name

the property name

Return Value

mixed

the value or null if not set

at line 137
static stdClass get_site()

Retrieves the site object ($SITE global).

Return Value

stdClass

Site object

at line 149
static int get_site_id()

Retrieves the SITEID constant value.

Return Value

int

Site ID