Elgg  Version 6.3
Public Member Functions | Public Attributes | 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 (protected PluginsCache $cache, protected Database $db, protected SessionManagerService $session_manager, protected EventsService $events, protected Translator $translator, protected ViewsService $views, protected Config $config, protected SystemMessagesService $system_messages, protected Invoker $invoker, Request $request)
 Constructor. More...
 
 getPath ()
 Get the plugin path for this installation, ending with slash. More...
 
 setBootPlugins (?array $plugins=null, bool $order_plugins=true)
 Set the list of active plugins according to the boot data cache. More...
 
 getDirsInDir (?string $dir=null)
 Returns a list of plugin directory names from a base directory. More...
 
 generateEntities ()
 Discovers plugins in the plugins_path setting and creates \ElggPlugin entities for them if they don't exist. More...
 
 get (string $plugin_id)
 Returns an \ElggPlugin object with the path $path. More...
 
 getMaxPriority ()
 Returns the highest priority of the plugins. More...
 
 isActive (string $plugin_id)
 Returns if a plugin is active for a current site. More...
 
 build ()
 Registers lifecycle events 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 (string $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...
 
 setPriority (\ElggPlugin $plugin, int $priority)
 Set plugin priority and adjust the priorities of other plugins. More...
 

Public Attributes

const BUNDLED_PLUGINS
 

Protected Member Functions

 disable (\ElggPlugin $plugin, \Exception $previous)
 Disable a plugin upon exception. More...
 
 orderPluginsByPriority (array $plugins=[], ?string $volatile_data_name=null)
 Sorts plugins by priority. More...
 

Protected Attributes

array $boot_plugins
 
Context $context
 

Detailed Description

Persistent, installation-wide key-value storage.

Definition at line 27 of file Plugins.php.

Constructor & Destructor Documentation

◆ __construct()

Elgg\Database\Plugins::__construct ( protected PluginsCache  $cache,
protected Database  $db,
protected SessionManagerService  $session_manager,
protected EventsService  $events,
protected Translator  $translator,
protected ViewsService  $views,
protected Config  $config,
protected SystemMessagesService  $system_messages,
protected Invoker  $invoker,
Request  $request 
)

Constructor.

Parameters
PluginsCache$cachePlugins cache
Database$dbDatabase
SessionManagerService$session_managerSession
EventsService$eventsEvents
Translator$translatorTranslator
ViewsService$viewsViews service
Config$configConfig
SystemMessagesService$system_messagesSystem messages
Invoker$invokerInvoker
Request$requestContext

Definition at line 87 of file Plugins.php.

Member Function Documentation

◆ boot()

Elgg\Database\Plugins::boot ( )

Boot the plugins.

Returns
void

Definition at line 441 of file Plugins.php.

◆ build()

Elgg\Database\Plugins::build ( )

Registers lifecycle events 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 389 of file Plugins.php.

◆ disable()

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 564 of file Plugins.php.

◆ find()

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

Returns an ordered list of plugins.

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

Definition at line 601 of file Plugins.php.

◆ generateEntities()

Elgg\Database\Plugins::generateEntities ( )

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. The \ElggPlugin object holds config data, so don't delete.

Returns
bool

Definition at line 198 of file Plugins.php.

◆ get()

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

Returns an \ElggPlugin object with the path $path.

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

Definition at line 307 of file Plugins.php.

◆ getDirsInDir()

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

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

Parameters
null | 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 163 of file Plugins.php.

◆ getMaxPriority()

Elgg\Database\Plugins::getMaxPriority ( )

Returns the highest priority of the plugins.

Returns
int

Definition at line 344 of file Plugins.php.

◆ getPath()

Elgg\Database\Plugins::getPath ( )

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

Returns
string

Definition at line 107 of file Plugins.php.

◆ init()

Elgg\Database\Plugins::init ( )

Initialize plugins.

Returns
void

Definition at line 465 of file Plugins.php.

◆ isActive()

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

Returns if a plugin is active for a current site.

Parameters
string$plugin_idThe plugin ID
Returns
bool

Definition at line 367 of file Plugins.php.

◆ orderPluginsByPriority()

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

Sorts plugins by priority.

Parameters
\ElggPlugin[]$pluginsArray of plugins
null | string$volatile_data_nameUse an optional volatile data name to retrieve priority
Returns
\ElggPlugin[]

Definition at line 679 of file Plugins.php.

◆ ready()

Elgg\Database\Plugins::ready ( )

Run plugin ready handlers.

Returns
void

Definition at line 489 of file Plugins.php.

◆ register()

Elgg\Database\Plugins::register ( )

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

Returns
void

Definition at line 417 of file Plugins.php.

◆ reindexPriorities()

Elgg\Database\Plugins::reindexPriorities ( )

Reindexes all plugin priorities starting at 1.

Returns
bool

Definition at line 775 of file Plugins.php.

◆ setBootPlugins()

Elgg\Database\Plugins::setBootPlugins ( ?array  $plugins = null,
bool  $order_plugins = true 
)

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

Parameters
\ElggPlugin[] | null$pluginsSet 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 119 of file Plugins.php.

◆ setPriorities()

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 \ElggPlugin->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 714 of file Plugins.php.

◆ setPriority()

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

Set plugin priority and adjust the priorities of other plugins.

Parameters
\ElggPlugin$pluginPlugin
int$priorityNew priority
Returns
int|false

Definition at line 787 of file Plugins.php.

◆ shutdown()

Elgg\Database\Plugins::shutdown ( )

Run plugin shutdown handlers.

Returns
void

Definition at line 537 of file Plugins.php.

◆ upgrade()

Elgg\Database\Plugins::upgrade ( )

Run plugin upgrade handlers.

Returns
void

Definition at line 513 of file Plugins.php.

Member Data Documentation

◆ $boot_plugins

array Elgg\Database\Plugins::$boot_plugins
protected

Definition at line 69 of file Plugins.php.

◆ $context

Context Elgg\Database\Plugins::$context
protected

Definition at line 71 of file Plugins.php.

◆ BUNDLED_PLUGINS

const Elgg\Database\Plugins::BUNDLED_PLUGINS

Definition at line 32 of file Plugins.php.


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