Methods summary
public
|
#
__construct( )
Initialize Plugin Manager
Initialize Plugin Manager
Overrides
|
public
array
|
#
getAll( integer $company_id, array $order = ['name' => 'asc'] )
Lists all installed plugins
Lists all installed plugins
Parameters
- $company_id
- The company ID
- $order
- The sort and order fields (optional, default name ascending)
Returns
array An array of stdClass objects representing installed plugins
|
public
array
|
#
getInstalled( )
Fetches all plugins installed in the system
Fetches all plugins installed in the system
Returns
array An array of stdClass objects, each representing an installed plugin record
|
public
array
|
#
getByDir( string $plugin_dir, integer $company_id = null )
Fetches a plugin for a given company, or all plugins installed in the system for the given plugin directory
Fetches a plugin for a given company, or all plugins installed in the system for the given plugin directory
Parameters
- $plugin_dir
- The directory name of the plugin to return results for
- $company_id
- The ID of the company to fetch plugins for
Returns
array An array of stdClass objects, each representing an installed plugin record
|
public
mixed
|
#
get( integer $plugin_id, boolean $detailed = false )
Fetches a single installed plugin.
Fetches a single installed plugin.
Parameters
- $plugin_id
- The plugin ID to fetch
- $detailed
- True to return detailed information about the plugin, false otherwise
Returns
mixed A stdClass object representing the installed plugin,
false if no such plugin exists or is not installed
|
public
array
|
#
getAvailable( integer $company_id = null )
Lists all available plugins (those that exist on the file system)
Lists all available plugins (those that exist on the file system)
Parameters
- $company_id
- The ID of the company to get available plugins for
Returns
array An array of stdClass objects representing available plugins
|
public
boolean
|
#
isInstalled( string $dir, integer $company_id = null )
Checks whether the given plugin is installed for the specified company
Checks whether the given plugin is installed for the specified company
Parameters
- $dir
- The plugin dir (in file_case)
- $company_id
The ID of the company to fetch for (null
checks if the plugin is installed across any company)
Returns
boolean True if the plugin is installed, false otherwise
|
public
boolean
|
#
isLastInstance( string $dir )
Checks whether the given plugin is the last instance installed
Checks whether the given plugin is the last instance installed
Parameters
- $dir
- The plugin dir (in file_case)
Returns
boolean True if the plugin is the last instance, false otherwise
|
public
integer
|
#
add( array $vars )
Adds the plugin to the system
Adds the plugin to the system
Parameters
- $vars
An array of plugin information including:
- dir The dir name for the plugin to be installed
- company_id The ID of the company the plugin should be installed for
- staff_group_id The ID of the staff group to grant access to all permissions created by this plugin (optional)
Returns
integer The ID of the plugin installed, void on error
|
public
|
#
upgrade( integer $plugin_id )
Runs the plugin's upgrade method to upgrade the plugin to match that of the plugin's file version.
Sets errors in PluginManager::errors() if any errors are set by the plugin's upgrade method.
Runs the plugin's upgrade method to upgrade the plugin to match that of the plugin's file version.
Sets errors in PluginManager::errors() if any errors are set by the plugin's upgrade method.
Parameters
- $plugin_id
- The ID of the plugin to upgrade
|
public
|
#
delete( integer $plugin_id )
Permanently and completely removes the plugin specified by $plugin_id
Permanently and completely removes the plugin specified by $plugin_id
Parameters
- $plugin_id
- The ID of the plugin to permanently remove
|
public
|
#
enable( integer $plugin_id )
Enables a plugin
Parameters
|
public
|
#
disable( integer $plugin_id )
Disables a plugin
Parameters
|
protected
|
#
clearNavCache( integer $company_id )
Clears the nav cache for the given company ID
Clears the nav cache for the given company ID
Parameters
- $company_id
- The ID of the company to clear nav cache for
|
public
|
#
addEvent( integer $plugin_id, array $vars )
Adds an event to the system with a callback to be invoked when the event is triggered
Adds an event to the system with a callback to be invoked when the event is triggered
Parameters
- $plugin_id
- The ID of the plugin to add an event for
- $vars
An array of event info including:
- event The event to register the callback under
- callback The public static callback to invoke
- enabled Sets whether the event is enabled (1 to enable, 0 to disable) (optional, default 1)
|
public
|
#
editEvent( integer $plugin_id, string $event, array $vars )
Updates the given plugin event
Updates the given plugin event
Parameters
- $plugin_id
- The ID of the plugin whose event to update
- $event
- The name of the plugin event to update
- $vars
An array of event fields to update including:
- callback The public static callback to invoke (optional)
- enabled Sets whether the event is enabled (1 to enable, 0 to disable) (optional)
|
public
|
#
deleteEvent( integer $plugin_id, string $event )
Removes the event from the plugin so the event will no longer be triggered
Removes the event from the plugin so the event will no longer be triggered
Parameters
- $plugin_id
- The ID of the plugin to remove the event from
- $event
- The event to remove from the plugin
|
public
|
#
addMessage( integer $plugin_id, array $vars )
Adds a message to the system
Adds a message to the system
Parameters
- $plugin_id
- The ID of the plugin to add a message for
- $vars
An array of message info including:
- action The name of the action that triggers the message
- type The level of the message ('staff', 'client', 'shared')
- tags A comma separated list of replacement tags (e.g. {client},{service.name})
- content A key/value list of messenger types and their default content ()
|
public
|
#
editMessage( integer $plugin_id, array $vars, integer $message_id )
Updates the given plugin message
Updates the given plugin message
Parameters
- $plugin_id
- The ID of the plugin to update the message for
- $vars
An array of message info including:
- action The name of the action that triggers the message
- type The level of the message ('staff', 'client', 'shared')
- tags A comma separated list of replacement tags (e.g. {client},{service.name})
- content A key/value list of messenger types and their default content ()
- $message_id
- The message ID to update
|
public
|
#
deleteMessage( string $action )
Removes the all message details for an action
Removes the all message details for an action
Parameters
- $action
- The action for the message to remove from the plugin
|
public
|
#
addAction( integer $plugin_id, array $vars, array $current_actions = [] )
Adds a plugin action
Parameters
- $plugin_id
- The ID pf the plugin for which to add this action
- $vars
An array of action fields to add including:
- location The identifier for the locations to display the action (optional, "nav_staff" by default)
('nav_client', 'nav_staff', 'nav_public', 'widget_client_home', 'widget_staff_home',
'widget_staff_client', 'widget_staff_billing', 'action_staff_client')
- url The URL of the action
- name The language definition naming this action
- options An array of key/value pairs to set for the given action (if necessary) (optional)
- enabled Sets whether the action is enabled (1 to enable, 0 to disable) (optional)
- $current_actions
- An array of existing actions already installed
|
public
|
#
deleteActions( integer $plugin_id, string $url = null )
Removes the action from the plugin
Removes the action from the plugin
Parameters
- $plugin_id
- The ID of the plugin to remove the action from
- $url
The URL of the specific record to delete,
otherwise defaults to delete all records for this plugin (optional)
|
public
|
#
addCard( integer $plugin_id, array $vars )
Adds a card to the system
Adds a card to the system
Parameters
- $plugin_id
- The ID of the plugin to register the card under
- $vars
An array of card fields including:
- level The level this card should be displayed on (client or staff) (optional, default client)
- callback A method defined by the plugin class for calculating the value of the card or fetching a custom html
- callback_type The callback type, 'value' to fetch the card value or
'html' to fetch the custom html code (optional, default value)
- text_color The text color in hexadecimal for this card (optional)
- background The background color in hexadecimal or path to the background image for this card (optional)
- background_type The background type, 'color' to set a hexadecimal background or
'image' to set an image background (optional, default color)
- label A string or language key appearing under the value as a label
- link The link to which the card will be pointed (optional)
- enabled Whether this card appears on client profiles by default
(1 to enable, 0 to disable) (optional, default 1)
|
public
|
#
editCard( integer $plugin_id, array $callback, string $level, array $vars )
Updates the given plugin card
Updates the given plugin card
Parameters
- $plugin_id
- The ID of the plugin whose card to update
- $callback
- The callback of the plugin card to update
- $level
- The level of the plugin card to update
- $vars
An array of action fields to update including:
- label A string or language key appearing under the value as a label
- link The card link URL (optional)
- text_color The text color in hexadecimal for this card (optional)
- background The background color in hexadecimal or path to the background image for this card (optional)
- background_type The background type, 'color' to set a hexadecimal background or
'image' to set an image background (optional, default color)
- enabled Whether this card appears on client profiles by default
(1 to enable, 0 to disable) (optional, default 1)
|
public
|
#
deleteCard( integer $plugin_id, mixed $callback = null, string $level = null )
Removes the card from the plugin
Removes the card from the plugin
Parameters
- $plugin_id
- The ID of the plugin to remove the card from
- $callback
- The callback of the plugin card to remove from the plugin (optional)
- $level
The level of the plugin card to remove, otherwise defaults to
delete all records for this card (optional)
|
public
|
#
addPermission( integer $plugin_id, array $vars )
Adds a permission to the system that is used to restrict access to a particular view
Adds a permission to the system that is used to restrict access to a particular view
Parameters
- $plugin_id
- The ID of the plugin to register the permission under
- $vars
An array of plugin fields including:
- group_alias The alias of the permission group this permission belongs to
- name The name of this permission
- alias The ACO alias for this permission (i.e. the Class name to apply to)
- action The action this ACO may control (i.e. the Method name of the alias to control access for)
|
public
|
#
deletePermission( integer $plugin_id, string $alias, string $action )
Removes the permission from the plugin
Removes the permission from the plugin
Parameters
- $plugin_id
- The ID of the plugin to remove the permission from
- $alias
- The alias of the specific record to delete,
- $action
- The action for which to remove a permission from the plugin
|
public
|
#
addPermissionGroup( integer $plugin_id, array $vars )
Adds a permission group to the system that is used to restrict access to a set of views
Adds a permission group to the system that is used to restrict access to a set of views
Parameters
- $plugin_id
- The ID of the plugin to register the permission group under
- $vars
An array of plugin fields including:
- name The name of this permission group
- level The level this permission group resides on (staff or client)
- alias The ACO alias for this permission group (i.e. the Class name to apply to)
|
public
|
#
deletePermissionGroup( integer $plugin_id, string $alias )
Removes the permission group from the plugin
Removes the permission group from the plugin
Parameters
- $plugin_id
- The ID of the plugin to remove the permission group from
- $alias
- The alias of the specific record to delete
|
public
array
|
#
getEvents( integer $company_id, string $event, bool/int $enabled = null )
Retrieves all callbacks that are registered for a particular event and company
Retrieves all callbacks that are registered for a particular event and company
Parameters
- $company_id
- The ID of the company the event is registered under
- $event
- The event being requested
- $enabled
- True for only enabled plugins/events, false for disabled, null for both
Returns
array An array of stdClass objects representing the registered callback events
|
public
array
|
#
getAllEvents( integer $plugin_id )
Retrieves all events from the given plugin
Retrieves all events from the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch events under
Returns
array An array of stdClass objects representing registered events
|
public
mixed
|
#
getEvent( integer $plugin_id, string $event )
Retrieves the specified event of the given plugin
Retrieves the specified event of the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch the event under
- $event
- The event to fetch
Returns
mixed A stdClass object representing the plugin event, false if not such plugin event exists.
|
public
array
|
#
getActions( integer $company_id, string $action, bool/int $enabled = null, boolean $translate = true )
Retrieves all actions that are registered for a particular action and company
Retrieves all actions that are registered for a particular action and company
Parameters
- $company_id
- The ID of the company the action is registered under
- $action
- The action being requested
- $enabled
- True for only enabled plugins/actions, false for disabled, null for both
- $translate
- Whether or not to translate the action names (optional, default true)
Returns
array An array of stdClass objects representing registered actions
|
public
array
|
#
getAllActions( integer $plugin_id, boolean $translate = true )
Retrieves all actions from the given plugin
Retrieves all actions from the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch actions under
- $translate
- Whether or not to translate the action names (optional, default true)
Returns
array An array of stdClass objects representing registered actions
|
public
mixed
|
#
getAction( integer $plugin_id, string $action, string $uri = null )
Retrieves the specified action from the given plugin
Retrieves the specified action from the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch the action under
- $action
- The action to fetch
- $uri
The URI of the specific record to retrieve,
otherwise defaults to the first record found (optional)
Returns
mixed A stdClass object representing the plugin action, false if no such plugin action exists.
|
public
array
|
#
getCards( integer $company_id, string $level = null, bool/int $enabled = null, boolean $translate = true )
Retrieves all cards that are registered for a particular level and company
Retrieves all cards that are registered for a particular level and company
Parameters
- $company_id
- The ID of the company the card is registered under
- $level
- The card's level being requested, null for both
- $enabled
- True for only enabled plugins/cards, false for disabled, null for both
- $translate
- Whether or not to translate the card labels (optional, default true)
Returns
array An array of stdClass objects representing registered cards
|
public
array
|
#
getAllCards( integer $plugin_id, boolean $translate = true )
Retrieves all cards from the given plugin
Retrieves all cards from the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch cards under
- $translate
- Whether or not to translate the card labels (optional, default true)
Returns
array An array of stdClass objects representing registered cards
|
public
mixed
|
#
getCard( integer $plugin_id, mixed $callback, string $level = null )
Retrieves the specified card from the given plugin
Retrieves the specified card from the given plugin
Parameters
- $plugin_id
- The ID of the plugin to fetch the action under
- $callback
- The callback of the plugin card to fetch
- $level
- The level of the plugin card to fetch
Returns
mixed A stdClass object representing the plugin card, false if no such plugin card exists.
|
public
string
|
#
translate( string $plugin_dir, string $term )
Retrieves the translated definition of the given term for the given plugin.
This assumes the plugin language file is the $plugin_dir concatenated with '_plugin'
Retrieves the translated definition of the given term for the given plugin.
This assumes the plugin language file is the $plugin_dir concatenated with '_plugin'
Parameters
- $plugin_dir
- The directory name of the plugin to return results for
- $term
- The language term from the plugin to translate
Returns
string The translated term, if found
|
public
Blesta\Core\Util\Events\Common\EventInterface
|
#
triggerEvents( Blesta\Core\Util\Events\Common\EventInterface $event )
Triggers the given event on all plugins registered to observe it
Triggers the given event on all plugins registered to observe it
Parameters
- $event
- The event to process
Returns
|