PHP Class Elgg\Database\Plugins

WARNING: API IN FLUX. DO NOT USE DIRECTLY.
Since: 1.10.0
Inheritance: use trait Elgg\Profilable
Show file Open project: elgg/elgg Class Usage Examples

Public Methods

Method Description
__construct ( Elgg\Cache\Pool $pool, PluginSettingsCache $cache ) Constructor
cache ( ElggPlugin $plugin ) Cache a reference to this plugin by its ID
checkProvides ( string $type, string $name, string $version = null, string $comparison = 'ge' ) : array Checks if a plugin is currently providing $type and $name, and optionally checking a version.
exists ( string $id ) : boolean Returns if a plugin exists in the system.
find ( string $status = 'active' ) : ElggPlugin[] Returns an ordered list of plugins
generateEntities ( ) : boolean Discovers plugins in the plugins_path setting and creates \ElggPlugin entities for them if they don't exist. If there are plugins with entities but not actual files, will disable the \ElggPlugin entities and mark as inactive.
get ( string $plugin_id ) : ElggPlugin | null Returns an \ElggPlugin object with the path $path.
getAllUserSettings ( integer $user_guid, string $plugin_id, boolean $return_obj = false ) : array Returns an array of all plugin user settings for a user.
getDependencyStrings ( array $dep ) : array Returns an array of parsed strings for a dependency in the format: array( 'type' => requires, conflicts, or provides.
getDirsInDir ( string $dir = null ) : array Returns a list of plugin directory names from a base directory.
getEntitiesFromUserSettings ( array $options = [] ) : mixed Returns entities based upon plugin user settings.
getMaxPriority ( ) : integer Returns the highest priority of the plugins
getProvides ( string $type = null, string $name = null ) : array Returns an array of all provides from all active plugins.
getSetting ( string $name, string $plugin_id, mixed $default = null ) : mixed Get setting for a plugin.
getUserSetting ( string $name, integer $user_guid, string $plugin_id, mixed $default = null ) : mixed Get a user specific setting for a plugin.
invalidateIsActiveCache ( ) : void Delete the cache holding whether plugins are active or not
invalidateProvidesCache ( ) : boolean Deletes all cached data on plugins being provided.
isActive ( string $plugin_id ) : boolean Returns if a plugin is active for a current site.
load ( ) : boolean Loads all active plugins in the order specified in the tool admin panel.
namespacePrivateSetting ( string $type, string $name, string $id = null ) : string Namespaces a string to be used as a private setting name for a plugin.
reindexPriorities ( ) : boolean Reindexes all plugin priorities starting at 1.
setBootPlugins ( array $plugins ) : void Set the list of active plugins according to the boot data cache
setPriorities ( array $order ) : boolean Reorder plugins to an order specified by the array.
setSetting ( string $name, mixed $value, string $plugin_id ) : boolean Set a setting for a plugin.
setUserSetting ( string $name, mixed $value, integer $user_guid, string $plugin_id ) : boolean Set a user specific setting for a plugin.
unsetAllSettings ( string $plugin_id ) : boolean Unsets all plugin settings for a plugin.
unsetSetting ( string $name, string $plugin_id ) : boolean Unsets a plugin setting.
unsetUserSetting ( string $name, integer $user_guid, string $plugin_id ) : boolean Unsets a user-specific plugin setting

Method Details

__construct() public method

Constructor
public __construct ( Elgg\Cache\Pool $pool, PluginSettingsCache $cache )
$pool Elgg\Cache\Pool Cache for referencing plugins by ID
$cache Elgg\Cache\PluginSettingsCache Plugin settings cache

cache() public method

Cache a reference to this plugin by its ID
public cache ( ElggPlugin $plugin )
$plugin ElggPlugin

checkProvides() public method

Checks if a plugin is currently providing $type and $name, and optionally checking a version.
public checkProvides ( string $type, string $name, string $version = null, string $comparison = 'ge' ) : array
$type string The type of the provide
$name string The name of the provide
$version string A version to check against
$comparison string The comparison operator to use in version_compare()
return array An array in the form array( 'status' => bool Does the provide exist?, 'value' => string The version provided )

exists() public method

Returns if a plugin exists in the system.
public exists ( string $id ) : boolean
$id string The plugin ID.
return boolean

find() public method

Returns an ordered list of plugins
public find ( string $status = 'active' ) : ElggPlugin[]
$status string The status of the plugins. active, inactive, or all.
return ElggPlugin[]

generateEntities() public method

The \ElggPlugin object holds config data, so don't delete.
public generateEntities ( ) : boolean
return boolean

get() public method

Returns an \ElggPlugin object with the path $path.
public get ( string $plugin_id ) : ElggPlugin | null
$plugin_id string The id (dir name) of the plugin. NOT the guid.
return ElggPlugin | null

getAllUserSettings() public method

Returns an array of all plugin user settings for a user.
See also: ElggPlugin::getAllUserSettings()
public getAllUserSettings ( integer $user_guid, string $plugin_id, boolean $return_obj = false ) : array
$user_guid integer The user GUID or 0 for the currently logged in user.
$plugin_id string The plugin ID (Required)
$return_obj boolean Return settings as an object? This can be used to in reusable views where the settings are passed as $vars['entity'].
return array

getDependencyStrings() public method

'name' => The name of the requirement / conflict 'value' => A string representing the expected value: <1, >=3, !=enabled 'local_value' => The current value, ("Not installed") 'comment' => Free form text to help resovle the problem ("Enable / Search for plugin ") )
public getDependencyStrings ( array $dep ) : array
$dep array An \ElggPluginPackage dependency array
return array

getDirsInDir() public method

Returns a list of plugin directory names from a base directory.
public getDirsInDir ( string $dir = null ) : array
$dir string A dir to scan for plugins. Defaults to config's plugins_path. Must have a trailing slash.
return array Array of directory names (not full paths)

getEntitiesFromUserSettings() public method

Takes all the options for {@link elgg_get_entities_from_private_settings()} in addition to the ones below.
public getEntitiesFromUserSettings ( array $options = [] ) : mixed
$options array Array in the format: plugin_id => STR The plugin id. Required. plugin_user_setting_names => null|ARR private setting names plugin_user_setting_values => null|ARR metadata values plugin_user_setting_name_value_pairs => null|ARR ( name => 'name', value => 'value', 'operand' => '=', ) Currently if multiple values are sent via an array (value => array('value1', 'value2') the pair's operand will be forced to "IN". plugin_user_setting_name_value_pairs_operator => null|STR The operator to use for combining (name = value) OPERATOR (name = value); default AND
return mixed int If count, int. If not count, array. false on errors.

getMaxPriority() public method

Returns the highest priority of the plugins
public getMaxPriority ( ) : integer
return integer

getProvides() public method

Array in the form array( 'provide_type' => array( 'provided_name' => array( 'version' => '1.8', 'provided_by' => 'provider_plugin_id' ) ) )
public getProvides ( string $type = null, string $name = null ) : array
$type string The type of provides to return
$name string A specific provided name to return. Requires $provide_type.
return array

getSetting() public method

Get setting for a plugin.
See also: ElggPlugin::getSetting()
public getSetting ( string $name, string $plugin_id, mixed $default = null ) : mixed
$name string The name of the setting.
$plugin_id string The plugin ID (Required)
$default mixed The default value to return if none is set
return mixed

getUserSetting() public method

Get a user specific setting for a plugin.
See also: ElggPlugin::getUserSetting()
public getUserSetting ( string $name, integer $user_guid, string $plugin_id, mixed $default = null ) : mixed
$name string The name of the setting.
$user_guid integer The user GUID or 0 for the currently logged in user.
$plugin_id string The plugin ID (Required)
$default mixed The default value to return if none is set
return mixed

invalidateIsActiveCache() public method

Delete the cache holding whether plugins are active or not
public invalidateIsActiveCache ( ) : void
return void

invalidateProvidesCache() public method

Deletes all cached data on plugins being provided.

isActive() public method

Returns if a plugin is active for a current site.
public isActive ( string $plugin_id ) : boolean
$plugin_id string The plugin ID
return boolean

load() public method

Loads all active plugins in the order specified in the tool admin panel.
public load ( ) : boolean
return boolean

namespacePrivateSetting() public method

For user_settings, two namespaces are added: a user setting namespace and the plugin id. For internal (plugin priority), there is a single internal namespace added.
public namespacePrivateSetting ( string $type, string $name, string $id = null ) : string
$type string The type of setting: user_setting or internal.
$name string The name to namespace.
$id string The plugin's ID to namespace with. Required for user_setting.
return string

reindexPriorities() public method

Reindexes all plugin priorities starting at 1.
public reindexPriorities ( ) : boolean
return boolean

setBootPlugins() public method

Set the list of active plugins according to the boot data cache
public setBootPlugins ( array $plugins ) : void
$plugins array Set of active plugins
return void

setPriorities() public method

Plugins not included in this array will be appended to the end.
public setPriorities ( array $order ) : boolean
$order array An array of plugin ids in the order to set them
return boolean

setSetting() public method

Set a setting for a plugin.
See also: ElggPlugin::setSetting()
public setSetting ( string $name, mixed $value, string $plugin_id ) : boolean
$name string The name of the setting - note, can't be "title".
$value mixed The value.
$plugin_id string The plugin ID (Required)
return boolean

setUserSetting() public method

Set a user specific setting for a plugin.
See also: ElggPlugin::setUserSetting()
public setUserSetting ( string $name, mixed $value, integer $user_guid, string $plugin_id ) : boolean
$name string The name. Note: cannot be "title".
$value mixed The value.
$user_guid integer The user GUID or 0 for the currently logged in user.
$plugin_id string The plugin ID (Required)
return boolean

unsetAllSettings() public method

Unsets all plugin settings for a plugin.
See also: ElggPlugin::unsetAllSettings()
public unsetAllSettings ( string $plugin_id ) : boolean
$plugin_id string The plugin ID (Required)
return boolean

unsetSetting() public method

Unsets a plugin setting.
See also: ElggPlugin::unsetSetting()
public unsetSetting ( string $name, string $plugin_id ) : boolean
$name string The name of the setting.
$plugin_id string The plugin ID (Required)
return boolean

unsetUserSetting() public method

Unsets a user-specific plugin setting
See also: ElggPlugin::unsetUserSetting()
public unsetUserSetting ( string $name, integer $user_guid, string $plugin_id ) : boolean
$name string Name of the setting
$user_guid integer The user GUID or 0 for the currently logged in user.
$plugin_id string The plugin ID (Required)
return boolean