Elgg  Version 3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Database\Plugins Class Reference

Persistent, installation-wide key-value storage. More...

Public Member Functions

 __construct (ElggCache $cache, Database $db, ElggSession $session, EventsService $events, Translator $translator, ViewsService $views, PrivateSettingsCache $private_settings_cache, Config $config, SystemMessagesService $system_messages, Context $context)
 Constructor. More...
 
 getPath ()
 Get the plugin path for this installation, ending with slash. More...
 
 setBootPlugins ($plugins, $order_plugins=true)
 Set the list of active plugins according to the boot data cache. More...
 
 clear ()
 Clear plugin caches. More...
 
 getDirsInDir ($dir=null)
 Returns a list of plugin directory names from a base directory. More...
 
 generateEntities ()
 Discovers plugins in the plugins_path setting and creates entities for them if they don't exist. More...
 
 cache (ElggPlugin $plugin)
 Cache a reference to this plugin by its ID. More...
 
 invalidateCache ($plugin_id)
 Remove plugin from cache. More...
 
 get ($plugin_id)
 Returns an object with the path $path. More...
 
 exists ($id)
 Returns if a plugin exists in the system. More...
 
 getMaxPriority ()
 Returns the highest priority of the plugins. More...
 
 isActive ($plugin_id)
 Returns if a plugin is active for a current site. More...
 
 build ()
 Registers lifecycle hooks for all active plugins sorted by their priority. More...
 
 register ()
 Autoload plugin classes and files Register views, translations and custom entity types. More...
 
 boot ()
 Boot the plugins. More...
 
 init ()
 Initialize plugins. More...
 
 ready ()
 Run plugin ready handlers. More...
 
 upgrade ()
 Run plugin upgrade handlers. More...
 
 shutdown ()
 Run plugin shutdown handlers. More...
 
 find ($status= 'active')
 Returns an ordered list of plugins. More...
 
 setPriorities (array $order)
 Reorder plugins to an order specified by the array. More...
 
 reindexPriorities ()
 Reindexes all plugin priorities starting at 1. More...
 
 namespacePrivateSetting ($type, $name, $id=null)
 Namespaces a string to be used as a private setting name for a plugin. More...
 
 getProvides ($type=null, $name=null)
 Returns an array of all provides from all active plugins. More...
 
 invalidateProvidesCache ()
 Deletes all cached data on plugins being provided. More...
 
 checkProvides ($type, $name, $version=null, $comparison= 'ge')
 Checks if a plugin is currently providing $type and $name, and optionally checking a version. More...
 
 getDependencyStrings ($dep)
 Returns an array of parsed strings for a dependency in the format: array( 'type' => requires, conflicts, or provides. More...
 
 getAllSettings (ElggPlugin $plugin)
 Get all settings (excluding user settings) for a plugin. More...
 
 getAllUserSettings (ElggPlugin $plugin, ElggUser $user=null)
 Returns an array of all plugin user settings for a user. More...
 
 setUserSetting ($name, $value, $user_guid=0, $plugin_id=null)
 Set a user specific setting for a plugin. More...
 
 unsetUserSetting ($name, $user_guid=0, $plugin_id=null)
 Unsets a user-specific plugin setting. More...
 
 getUserSetting ($name, $user_guid=0, $plugin_id=null, $default=null)
 Get a user specific setting for a plugin. More...
 
 setSetting ($name, $value, $plugin_id)
 Set a setting for a plugin. More...
 
 getSetting ($name, $plugin_id, $default=null)
 Get setting for a plugin. More...
 
 unsetSetting ($name, $plugin_id)
 Unsets a plugin setting. More...
 
 unsetAllSettings ($plugin_id)
 Unsets all plugin settings for a plugin. More...
 
 getEntitiesFromUserSettings (array $options=[])
 Returns entities based upon plugin user settings. More...
 
 setPriority (ElggPlugin $plugin, $priority)
 Set plugin priority and adjust the priorities of other plugins. More...
 

Protected Member Functions

 registerRoot ()
 Register root level plugin views and translations. More...
 
 bootRoot ()
 Boot root level custom plugin for starter-project installation. More...
 
 disable (ElggPlugin $plugin, Exception $previous)
 Disable a plugin upon exception. More...
 
 orderPluginsByPriority ($plugins=[], $volatile_data_name=null)
 Sorts plugins by priority. More...
 

Protected Attributes

 $boot_plugins
 
 $provides_cache
 
 $db
 
 $session
 
 $events
 
 $translator
 
 $views
 
 $private_settings_cache
 
 $config
 
 $system_messages
 
 $context
 

Detailed Description

Persistent, installation-wide key-value storage.

WARNING: API IN FLUX. DO NOT USE DIRECTLY.

Definition at line 36 of file Plugins.php.

Constructor & Destructor Documentation

Elgg\Database\Plugins::__construct ( ElggCache  $cache,
Database  $db,
ElggSession  $session,
EventsService  $events,
Translator  $translator,
ViewsService  $views,
PrivateSettingsCache  $private_settings_cache,
Config  $config,
SystemMessagesService  $system_messages,
Context  $context 
)

Constructor.

Parameters
ElggCache$cacheCache for referencing plugins by ID
Database$dbDatabase
ElggSession$sessionSession
EventsService$eventsEvents
Translator$translatorTranslator
ViewsService$viewsViews service
PrivateSettingsCache$private_settings_cacheSettings cache
Config$configConfig
SystemMessagesService$system_messagesSystem messages
Context$contextContext

Definition at line 112 of file Plugins.php.

Member Function Documentation

Elgg\Database\Plugins::boot ( )

Boot the plugins.

plugins_boot:before system

Returns
void

Definition at line 535 of file Plugins.php.

Elgg\Database\Plugins::bootRoot ( )
protected

Boot root level custom plugin for starter-project installation.

Returns
void

Definition at line 596 of file Plugins.php.

Elgg\Database\Plugins::build ( )

Registers lifecycle hooks for all active plugins sorted by their priority.

Note
This is called on every page load. If a plugin is active and problematic, it will be disabled and a visible error emitted. This does not check the deps system because that was too slow.
Returns
bool

Definition at line 474 of file Plugins.php.

Elgg\Database\Plugins::cache ( ElggPlugin  $plugin)

Cache a reference to this plugin by its ID.

Parameters
ElggPlugin$pluginthe plugin to cache
Returns
void

Definition at line 339 of file Plugins.php.

Elgg\Database\Plugins::checkProvides (   $type,
  $name,
  $version = null,
  $comparison = 'ge' 
)

Checks if a plugin is currently providing $type and $name, and optionally checking a version.

Parameters
string$typeThe type of the provide
string$nameThe name of the provide
string$versionA version to check against
string$comparisonThe comparison operator to use in version_compare()
Returns
array An array in the form array( 'status' => bool Does the provide exist?, 'value' => string The version provided )

Definition at line 1060 of file Plugins.php.

Elgg\Database\Plugins::clear ( )

Clear plugin caches.

Returns
void

Definition at line 191 of file Plugins.php.

Elgg\Database\Plugins::disable ( ElggPlugin  $plugin,
Exception  $previous 
)
protected

Disable a plugin upon exception.

Parameters
ElggPlugin$pluginPlugin entity to disable
Exception$previousException thrown
Returns
void

Definition at line 735 of file Plugins.php.

Elgg\Database\Plugins::exists (   $id)

Returns if a plugin exists in the system.

Warning
This checks only plugins that are registered in the system! If the plugin cache is outdated, be sure to regenerate it with _elgg_generate_plugin_objects() first.
Parameters
string$idThe plugin ID.
Returns
bool

Definition at line 417 of file Plugins.php.

Elgg\Database\Plugins::find (   $status = 'active')

Returns an ordered list of plugins.

Parameters
string$statusThe status of the plugins. active, inactive, or all.
Returns
ElggPlugin[]

Definition at line 777 of file Plugins.php.

Elgg\Database\Plugins::generateEntities ( )

Discovers plugins in the plugins_path setting and creates entities for them if they don't exist.

If there are plugins with entities but not actual files, will disable the entities and mark as inactive. The object holds config data, so don't delete.

Returns
bool
Exceptions
DatabaseException

Definition at line 241 of file Plugins.php.

Elgg\Database\Plugins::get (   $plugin_id)

Returns an object with the path $path.

Parameters
string$plugin_idThe id (dir name) of the plugin. NOT the guid.
Returns
ElggPlugin|null

Definition at line 371 of file Plugins.php.

Elgg\Database\Plugins::getAllSettings ( ElggPlugin  $plugin)

Get all settings (excluding user settings) for a plugin.

Parameters
\ElggPlugin$pluginPlugin
Returns
string[]
Exceptions
DatabaseException

Definition at line 1216 of file Plugins.php.

Elgg\Database\Plugins::getAllUserSettings ( ElggPlugin  $plugin,
ElggUser  $user = null 
)

Returns an array of all plugin user settings for a user.

Parameters
ElggPlugin$pluginPlugin
ElggUser$userUser
Returns
array
See also
ElggPlugin::getAllUserSettings()
Exceptions
DatabaseException

Definition at line 1260 of file Plugins.php.

Elgg\Database\Plugins::getDependencyStrings (   $dep)

Returns an array of parsed strings for a dependency in the format: array( 'type' => requires, conflicts, or provides.

'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 <link>") )

Parameters
array$depAn dependency array
Returns
false|array

Definition at line 1095 of file Plugins.php.

Elgg\Database\Plugins::getDirsInDir (   $dir = null)

Returns a list of plugin directory names from a base directory.

Parameters
string$dirA dir to scan for plugins. Defaults to config's plugins_path. Must have a trailing slash.
Returns
array Array of directory names (not full paths)

Definition at line 204 of file Plugins.php.

Elgg\Database\Plugins::getEntitiesFromUserSettings ( array  $options = [])

Returns entities based upon plugin user settings.

Takes all the options for elgg_get_entities_from_private_settings() in addition to the ones below.

Parameters
array$optionsArray 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

Returns
mixed int If count, int. If not count, array. false on errors.

Definition at line 1449 of file Plugins.php.

Elgg\Database\Plugins::getMaxPriority ( )

Returns the highest priority of the plugins.

Returns
int
Exceptions
DatabaseException

Definition at line 427 of file Plugins.php.

Elgg\Database\Plugins::getPath ( )

Get the plugin path for this installation, ending with slash.

Returns
string

Definition at line 141 of file Plugins.php.

Elgg\Database\Plugins::getProvides (   $type = null,
  $name = null 
)

Returns an array of all provides from all active plugins.

Array in the form array( 'provide_type' => array( 'provided_name' => array( 'version' => '1.8', 'provided_by' => 'provider_plugin_id' ) ) )

Parameters
string$typeThe type of provides to return
string$nameA specific provided name to return. Requires $provide_type.
Returns
array|false

Definition at line 993 of file Plugins.php.

Elgg\Database\Plugins::getSetting (   $name,
  $plugin_id,
  $default = null 
)

Get setting for a plugin.

Parameters
string$nameThe name of the setting.
string$plugin_idThe plugin ID (Required)
mixed$defaultThe default value to return if none is set
Returns
mixed
See also
::getSetting()

Definition at line 1378 of file Plugins.php.

Elgg\Database\Plugins::getUserSetting (   $name,
  $user_guid = 0,
  $plugin_id = null,
  $default = null 
)

Get a user specific setting for a plugin.

Parameters
string$nameThe name of the setting.
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
mixed$defaultThe default value to return if none is set
Returns
mixed
See also
::getUserSetting()

Definition at line 1340 of file Plugins.php.

Elgg\Database\Plugins::init ( )

Initialize plugins.

init system

Returns
void

Definition at line 617 of file Plugins.php.

Elgg\Database\Plugins::invalidateCache (   $plugin_id)

Remove plugin from cache.

Parameters
string$plugin_idPlugin ID
Returns
void

Definition at line 353 of file Plugins.php.

Elgg\Database\Plugins::invalidateProvidesCache ( )

Deletes all cached data on plugins being provided.

Returns
boolean

Definition at line 1040 of file Plugins.php.

Elgg\Database\Plugins::isActive (   $plugin_id)

Returns if a plugin is active for a current site.

Parameters
string$plugin_idThe plugin ID
Returns
bool

Definition at line 452 of file Plugins.php.

Elgg\Database\Plugins::namespacePrivateSetting (   $type,
  $name,
  $id = null 
)

Namespaces a string to be used as a private setting name for a plugin.

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.

Parameters
string$typeThe type of setting: user_setting or internal.
string$nameThe name to namespace.
string$idThe plugin's ID to namespace with. Required for user_setting.
Returns
string

Definition at line 958 of file Plugins.php.

Elgg\Database\Plugins::orderPluginsByPriority (   $plugins = [],
  $volatile_data_name = null 
)
protected

Sorts plugins by priority.

Parameters

Definition at line 853 of file Plugins.php.

Elgg\Database\Plugins::ready ( )

Run plugin ready handlers.

ready system

Returns
void

Definition at line 646 of file Plugins.php.

Elgg\Database\Plugins::register ( )

Autoload plugin classes and files Register views, translations and custom entity types.

plugins_load system

Returns
void

Definition at line 504 of file Plugins.php.

Elgg\Database\Plugins::registerRoot ( )
protected

Register root level plugin views and translations.

Returns
void

Definition at line 567 of file Plugins.php.

Elgg\Database\Plugins::reindexPriorities ( )

Reindexes all plugin priorities starting at 1.

Returns
bool

Definition at line 940 of file Plugins.php.

Elgg\Database\Plugins::setBootPlugins (   $plugins,
  $order_plugins = true 
)

Set the list of active plugins according to the boot data cache.

Parameters
ElggPlugin[]|null$plugins Set of active plugins
bool$order_pluginsMake sure plugins are saved in the correct order (set to false if provided plugins are already sorted)
Returns
void

Definition at line 157 of file Plugins.php.

Elgg\Database\Plugins::setPriorities ( array  $order)

Reorder plugins to an order specified by the array.

Plugins not included in this array will be appended to the end.

Note
This doesn't use the ->setPriority() method because all plugins are being changed and we don't want it to automatically reorder plugins.
Parameters
array$orderAn array of plugin ids in the order to set them
Returns
bool

Definition at line 889 of file Plugins.php.

Elgg\Database\Plugins::setPriority ( ElggPlugin  $plugin,
  $priority 
)

Set plugin priority and adjust the priorities of other plugins.

Parameters
ElggPlugin$pluginPlugin
int$priorityNew priority
Returns
int|false
Exceptions
DatabaseException

Definition at line 1497 of file Plugins.php.

Elgg\Database\Plugins::setSetting (   $name,
  $value,
  $plugin_id 
)

Set a setting for a plugin.

Parameters
string$nameThe name of the setting - note, can't be "title".
mixed$valueThe value.
string$plugin_idThe plugin ID (Required)
Returns
bool
See also
::setSetting()

Definition at line 1359 of file Plugins.php.

Elgg\Database\Plugins::setUserSetting (   $name,
  $value,
  $user_guid = 0,
  $plugin_id = null 
)

Set a user specific setting for a plugin.

Parameters
string$nameThe name. Note: cannot be "title".
mixed$valueThe value.
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
Returns
bool
See also
::setUserSetting()

Definition at line 1301 of file Plugins.php.

Elgg\Database\Plugins::shutdown ( )

Run plugin shutdown handlers.

shutdown system

Returns
void

Definition at line 704 of file Plugins.php.

Elgg\Database\Plugins::unsetAllSettings (   $plugin_id)

Unsets all plugin settings for a plugin.

Parameters
string$plugin_idThe plugin ID (Required)
Returns
bool
See also
::unsetAllSettings()

Definition at line 1413 of file Plugins.php.

Elgg\Database\Plugins::unsetSetting (   $name,
  $plugin_id 
)

Unsets a plugin setting.

Parameters
string$nameThe name of the setting.
string$plugin_idThe plugin ID (Required)
Returns
bool
See also
::unsetSetting()

Definition at line 1396 of file Plugins.php.

Elgg\Database\Plugins::unsetUserSetting (   $name,
  $user_guid = 0,
  $plugin_id = null 
)

Unsets a user-specific plugin setting.

Parameters
string$nameName of the setting
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
Returns
bool
See also
::unsetUserSetting()

Definition at line 1320 of file Plugins.php.

Elgg\Database\Plugins::upgrade ( )

Run plugin upgrade handlers.

upgrade system

Returns
void

Definition at line 675 of file Plugins.php.

Member Data Documentation

Elgg\Database\Plugins::$boot_plugins
protected

Definition at line 45 of file Plugins.php.

Elgg\Database\Plugins::$config
protected

Definition at line 85 of file Plugins.php.

Elgg\Database\Plugins::$context
protected

Definition at line 95 of file Plugins.php.

Elgg\Database\Plugins::$db
protected

Definition at line 55 of file Plugins.php.

Elgg\Database\Plugins::$events
protected

Definition at line 65 of file Plugins.php.

Elgg\Database\Plugins::$private_settings_cache
protected

Definition at line 80 of file Plugins.php.

Elgg\Database\Plugins::$provides_cache
protected

Definition at line 50 of file Plugins.php.

Elgg\Database\Plugins::$session
protected

Definition at line 60 of file Plugins.php.

Elgg\Database\Plugins::$system_messages
protected

Definition at line 90 of file Plugins.php.

Elgg\Database\Plugins::$translator
protected

Definition at line 70 of file Plugins.php.

Elgg\Database\Plugins::$views
protected

Definition at line 75 of file Plugins.php.


The documentation for this class was generated from the following file: