PluginManager extends AppModel
Plugin manager. Handles installing/uninstalling plugins through their respective plugin handlers.
Table of Contents
Methods
| __construct() | Initialize Plugin Manager |
| add() | Adds the plugin to the system |
| addAction() | Adds a plugin action |
| addCard() | Adds a card to the system |
| addEvent() | Adds an event to the system with a callback to be invoked when the event is triggered |
| addMessage() | Adds a message to the system |
| addPermission() | Adds a permission to the system that is used to restrict access to a particular view |
| addPermissionGroup() | Adds a permission group to the system that is used to restrict access to a set of views |
| delete() | Permanently and completely removes the plugin specified by $plugin_id |
| deleteActions() | Removes the action from the plugin |
| deleteCard() | Removes the card from the plugin |
| deleteEvent() | Removes the event from the plugin so the event will no longer be triggered |
| deleteMessage() | Removes the all message details for an action |
| deletePermission() | Removes the permission from the plugin |
| deletePermissionGroup() | Removes the permission group from the plugin |
| disable() | Disables a plugin |
| editCard() | Updates the given plugin card |
| editEvent() | Updates the given plugin event |
| editMessage() | Updates the given plugin message |
| enable() | Enables a plugin |
| get() | Fetches a single installed plugin. |
| getAction() | Retrieves the specified action from the given plugin |
| getActions() | Retrieves all actions that are registered for a particular action and company |
| getAll() | Lists all installed plugins |
| getAllActions() | Retrieves all actions from the given plugin |
| getAllCards() | Retrieves all cards from the given plugin |
| getAllEvents() | Retrieves all events from the given plugin |
| getAvailable() | Lists all available plugins (those that exist on the file system) |
| getByDir() | Fetches a plugin for a given company, or all plugins installed in the system for the given plugin directory |
| getCard() | Retrieves the specified card from the given plugin |
| getCards() | Retrieves all cards that are registered for a particular level and company |
| getEvent() | Retrieves the specified event of the given plugin |
| getEvents() | Retrieves all callbacks that are registered for a particular event and company |
| getInstalled() | Fetches all plugins installed in the system |
| isInstalled() | Checks whether the given plugin is installed for the specified company |
| isLastInstance() | Checks whether the given plugin is the last instance installed |
| translate() | Retrieves the translated definition of the given term for the given plugin. |
| triggerEvents() | Triggers the given event on all plugins registered to observe it |
| upgrade() | Runs the plugin's upgrade method to upgrade the plugin to match that of the plugin's file version. |
| clearNavCache() | Clears the nav cache for the given company ID |
| convertOldActionParams() | Allow backward compatibility for plugin_action parameters by converting them to the new form |
| fetchCards() | Fetches all plugin cards |
| fetchEvents() | Fetches all plugin events |
| formatCard() | Formats the given plugin card |
| formatCards() | Format the plugin cards |
| formatCardUpgrade() | Formats a card during an upgrade |
| formatEventUpgrade() | Formats an event during an upgrade |
| getActionsByPlugin() | Retrieves all actians that are registered for a particular plugin |
| getAddRules() | Returns all common rules for plugins |
| getCardRules() | Retrieves the plugin cards rules for add/edit |
| getCardsByPlugin() | Retrieves all cards that are registered for a particular plugin |
| getEventRules() | Retrieves the plugin event rules for add/edit |
| getEventsByPlugin() | Retrieves all events that are registered for a particular plugin |
| getMessagesPlugin() | Retrieves all message templates that are registered for a particular plugin |
| getPluginInfo() | Fetch information about the given plugin object |
| getTranslation() | Retrieves the translation of the given term, if one is set, otherwise the term itself |
| invokePluginEvents() | Invokes the plugin event on all registered plugins |
| loadPlugin() | Instantiates the given plugin and returns its instance |
| setVersion() | Updates all installed plugins with the version given |
| translateArray() | Translates the given $values array for all matching $keys |
| translateCard() | Translates the names of language definitions within the card |
Methods
__construct()
Initialize Plugin Manager
public
__construct() : mixed
add()
Adds the plugin to the system
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
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)
Return values
int —The ID of the plugin installed, void on error
addAction()
Adds a plugin action
public
addAction(int $plugin_id, array<string|int, mixed> $vars[, array<string|int, mixed> $current_actions = [] ]) : mixed
Parameters
- $plugin_id : int
-
The ID pf the plugin for which to add this action
- $vars : array<string|int, mixed>
-
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 : array<string|int, mixed> = []
-
An array of existing actions already installed
addCard()
Adds a card to the system
public
addCard(int $plugin_id, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to register the card under
- $vars : array<string|int, mixed>
-
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)
addEvent()
Adds an event to the system with a callback to be invoked when the event is triggered
public
addEvent(int $plugin_id, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to add an event for
- $vars : array<string|int, mixed>
-
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)
addMessage()
Adds a message to the system
public
addMessage(int $plugin_id, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to add a message for
- $vars : array<string|int, mixed>
-
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 ()
addPermission()
Adds a permission to the system that is used to restrict access to a particular view
public
addPermission(int $plugin_id, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to register the permission under
- $vars : array<string|int, mixed>
-
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)
addPermissionGroup()
Adds a permission group to the system that is used to restrict access to a set of views
public
addPermissionGroup(int $plugin_id, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to register the permission group under
- $vars : array<string|int, mixed>
-
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)
delete()
Permanently and completely removes the plugin specified by $plugin_id
public
delete(int $plugin_id) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to permanently remove
deleteActions()
Removes the action from the plugin
public
deleteActions(int $plugin_id[, string $url = null ]) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to remove the action from
- $url : string = null
-
The URL of the specific record to delete, otherwise defaults to delete all records for this plugin (optional)
deleteCard()
Removes the card from the plugin
public
deleteCard(int $plugin_id[, mixed $callback = null ][, string $level = null ]) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to remove the card from
- $callback : mixed = null
-
The callback of the plugin card to remove from the plugin (optional)
- $level : string = null
-
The level of the plugin card to remove, otherwise defaults to delete all records for this card (optional)
deleteEvent()
Removes the event from the plugin so the event will no longer be triggered
public
deleteEvent(int $plugin_id, string $event) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to remove the event from
- $event : string
-
The event to remove from the plugin
deleteMessage()
Removes the all message details for an action
public
deleteMessage(string $action) : mixed
Parameters
- $action : string
-
The action for the message to remove from the plugin
deletePermission()
Removes the permission from the plugin
public
deletePermission(int $plugin_id, string $alias, string $action) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to remove the permission from
- $alias : string
-
The alias of the specific record to delete,
- $action : string
-
The action for which to remove a permission from the plugin
deletePermissionGroup()
Removes the permission group from the plugin
public
deletePermissionGroup(int $plugin_id, string $alias) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to remove the permission group from
- $alias : string
-
The alias of the specific record to delete
disable()
Disables a plugin
public
disable(int $plugin_id) : mixed
Parameters
- $plugin_id : int
editCard()
Updates the given plugin card
public
editCard(int $plugin_id, array<string|int, mixed> $callback, string $level, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin whose card to update
- $callback : array<string|int, mixed>
-
The callback of the plugin card to update
- $level : string
-
The level of the plugin card to update
- $vars : array<string|int, mixed>
-
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)
editEvent()
Updates the given plugin event
public
editEvent(int $plugin_id, string $event, array<string|int, mixed> $vars) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin whose event to update
- $event : string
-
The name of the plugin event to update
- $vars : array<string|int, mixed>
-
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)
editMessage()
Updates the given plugin message
public
editMessage(int $plugin_id, array<string|int, mixed> $vars, int $message_id) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to update the message for
- $vars : array<string|int, mixed>
-
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 : int
-
The message ID to update
enable()
Enables a plugin
public
enable(int $plugin_id) : mixed
Parameters
- $plugin_id : int
get()
Fetches a single installed plugin.
public
get(int $plugin_id[, bool $detailed = false ][, int $company_id = null ]) : mixed
Parameters
- $plugin_id : int
-
The plugin ID to fetch
- $detailed : bool = false
-
True to return detailed information about the plugin, false otherwise
- $company_id : int = null
-
The company ID to filter on, null for no filter, false for current company (optional, default false)
Return values
mixed —A stdClass object representing the installed plugin, false if no such plugin exists or is not installed
getAction()
Retrieves the specified action from the given plugin
public
getAction(int $plugin_id, string $action[, string $uri = null ]) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch the action under
- $action : string
-
The action to fetch
- $uri : string = null
-
The URI of the specific record to retrieve, otherwise defaults to the first record found (optional)
Return values
mixed —A stdClass object representing the plugin action, false if no such plugin action exists.
getActions()
Retrieves all actions that are registered for a particular action and company
public
getActions(int $company_id, string $action[, bool $enabled = null ][, bool $translate = true ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company the action is registered under
- $action : string
-
The action being requested
- $enabled : bool = null
-
True for only enabled plugins/actions, false for disabled, null for both
- $translate : bool = true
-
Whether or not to translate the action names (optional, default true)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered actions
getAll()
Lists all installed plugins
public
getAll(int $company_id[, string $order = ['name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The company ID
- $order : string = ['name' => 'asc']
-
The sort and order fields (optional, default name ascending)
Return values
array<string|int, mixed> —An array of stdClass objects representing installed plugins
getAllActions()
Retrieves all actions from the given plugin
public
getAllActions(int $plugin_id[, bool $translate = true ]) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch actions under
- $translate : bool = true
-
Whether or not to translate the action names (optional, default true)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered actions
getAllCards()
Retrieves all cards from the given plugin
public
getAllCards(int $plugin_id[, bool $translate = true ]) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch cards under
- $translate : bool = true
-
Whether or not to translate the card labels (optional, default true)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered cards
getAllEvents()
Retrieves all events from the given plugin
public
getAllEvents(int $plugin_id) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch events under
Return values
array<string|int, mixed> —An array of stdClass objects representing registered events
getAvailable()
Lists all available plugins (those that exist on the file system)
public
getAvailable([int $company_id = null ]) : array<string|int, mixed>
Parameters
- $company_id : int = null
-
The ID of the company to get available plugins for
Return values
array<string|int, mixed> —An array of stdClass objects representing available plugins
getByDir()
Fetches a plugin for a given company, or all plugins installed in the system for the given plugin directory
public
getByDir(string $plugin_dir[, int $company_id = null ]) : array<string|int, mixed>
Parameters
- $plugin_dir : string
-
The directory name of the plugin to return results for
- $company_id : int = null
-
The ID of the company to fetch plugins for
Return values
array<string|int, mixed> —An array of stdClass objects, each representing an installed plugin record
getCard()
Retrieves the specified card from the given plugin
public
getCard(int $plugin_id, mixed $callback[, string $level = null ]) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch the action under
- $callback : mixed
-
The callback of the plugin card to fetch
- $level : string = null
-
The level of the plugin card to fetch
Return values
mixed —A stdClass object representing the plugin card, false if no such plugin card exists.
getCards()
Retrieves all cards that are registered for a particular level and company
public
getCards(int $company_id[, string $level = null ][, bool $enabled = null ][, bool $translate = true ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company the card is registered under
- $level : string = null
-
The card's level being requested, null for both
- $enabled : bool = null
-
True for only enabled plugins/cards, false for disabled, null for both
- $translate : bool = true
-
Whether or not to translate the card labels (optional, default true)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered cards
getEvent()
Retrieves the specified event of the given plugin
public
getEvent(int $plugin_id, string $event) : mixed
Parameters
- $plugin_id : int
-
The ID of the plugin to fetch the event under
- $event : string
-
The event to fetch
Return values
mixed —A stdClass object representing the plugin event, false if not such plugin event exists.
getEvents()
Retrieves all callbacks that are registered for a particular event and company
public
getEvents(int $company_id, string $event[, bool $enabled = null ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company the event is registered under
- $event : string
-
The event being requested
- $enabled : bool = null
-
True for only enabled plugins/events, false for disabled, null for both
Return values
array<string|int, mixed> —An array of stdClass objects representing the registered callback events
getInstalled()
Fetches all plugins installed in the system
public
getInstalled() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of stdClass objects, each representing an installed plugin record
isInstalled()
Checks whether the given plugin is installed for the specified company
public
isInstalled(string $dir[, int $company_id = null ]) : bool
Parameters
- $dir : string
-
The plugin dir (in file_case)
- $company_id : int = null
-
The ID of the company to fetch for (null checks if the plugin is installed across any company)
Return values
bool —True if the plugin is installed, false otherwise
isLastInstance()
Checks whether the given plugin is the last instance installed
public
isLastInstance(string $dir) : bool
Parameters
- $dir : string
-
The plugin dir (in file_case)
Return values
bool —True if the plugin is the last instance, false otherwise
translate()
Retrieves the translated definition of the given term for the given plugin.
public
translate(string $plugin_dir, string $term) : string
This assumes the plugin language file is the $plugin_dir concatenated with '_plugin'
Parameters
- $plugin_dir : string
-
The directory name of the plugin to return results for
- $term : string
-
The language term from the plugin to translate
Return values
string —The translated term, if found
triggerEvents()
Triggers the given event on all plugins registered to observe it
public
triggerEvents(EventInterface $event) : EventInterface
Parameters
- $event : EventInterface
-
The event to process
Return values
EventInterface —The processed event object
upgrade()
Runs the plugin's upgrade method to upgrade the plugin to match that of the plugin's file version.
public
upgrade(int $plugin_id) : mixed
Sets errors in PluginManager::errors() if any errors are set by the plugin's upgrade method.
Parameters
- $plugin_id : int
-
The ID of the plugin to upgrade
clearNavCache()
Clears the nav cache for the given company ID
protected
clearNavCache(int $company_id) : mixed
Parameters
- $company_id : int
-
The ID of the company to clear nav cache for
convertOldActionParams()
Allow backward compatibility for plugin_action parameters by converting them to the new form
private
convertOldActionParams(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
A list of parameters for the plugin action
Return values
array<string|int, mixed> —A list of var sets each representing a plugin action
fetchCards()
Fetches all plugin cards
private
fetchCards(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
-
An array of options including:
- company_id The ID of the company whose cards to fetch (optional)
- plugin_id The ID of the plugin whose cards to fetch (optional)
- level The level of the plugin card to fetch (optional)
- enabled 1, 0, or null; what enabled status of actions to fetch (optional, default null)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered actions
fetchEvents()
Fetches all plugin events
private
fetchEvents(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
-
An array of options including:
- company_id The ID of the company whose events to fetch (optional)
- plugin_id The ID of the plugin whose events to fetch (optional)
- event The specific plugin event to fetch (optional)
- enabled 1, 0, or null; what enabled status of events to fetch (optional, default null)
Return values
array<string|int, mixed> —An array of stdClass objects representing registered events
formatCard()
Formats the given plugin card
private
formatCard(stdClass $card[, bool $translate = true ]) : stdClass
Parameters
- $card : stdClass
-
The stdClass object representing the plugin card
- $translate : bool = true
-
Whether or not to translate any language definitions (optional, default true)
Return values
stdClass —The stdClass $card formatted
formatCards()
Format the plugin cards
private
formatCards(array<string|int, mixed> $cards[, bool $translate = true ]) : array<string|int, mixed>
Parameters
- $cards : array<string|int, mixed>
-
A list of stdClass objects representing plugin cards to format
- $translate : bool = true
-
Whether or not to translate any language definitions (optional, default true)
Return values
array<string|int, mixed> —The given $cards formatted
formatCardUpgrade()
Formats a card during an upgrade
private
formatCardUpgrade(array<string|int, mixed> $card, array<string|int, mixed> $current_cards) : array<string|int, mixed>
Parameters
- $card : array<string|int, mixed>
-
The card being upgraded
- $current_cards : array<string|int, mixed>
-
An array of existing cards already installed
Tags
Return values
array<string|int, mixed> —The formatted card
formatEventUpgrade()
Formats an event during an upgrade
private
formatEventUpgrade(array<string|int, mixed> $event, array<string|int, mixed> $current_events) : array<string|int, mixed>
Parameters
- $event : array<string|int, mixed>
-
The event being upgraded
- $current_events : array<string|int, mixed>
-
An array of existing events already installed
Tags
Return values
array<string|int, mixed> —The formatted event
getActionsByPlugin()
Retrieves all actians that are registered for a particular plugin
private
getActionsByPlugin(int $plugin_id) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin
Return values
array<string|int, mixed> —An array of stdClass objects representing registered actions
getAddRules()
Returns all common rules for plugins
private
getAddRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
The input vars
Return values
array<string|int, mixed> —Common plugin rules
getCardRules()
Retrieves the plugin cards rules for add/edit
private
getCardRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
An array of input data
- $edit : bool = false
-
Whether or not to fetch the rules for an edit (optional, default false)
Return values
array<string|int, mixed> —An array of input validation rules including:
- plugin_id The ID of the plugin
- 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)
getCardsByPlugin()
Retrieves all cards that are registered for a particular plugin
private
getCardsByPlugin(int $plugin_id) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin
Return values
array<string|int, mixed> —An array of stdClass objects representing registered cards
getEventRules()
Retrieves the plugin event rules for add/edit
private
getEventRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
An array of input data
- $edit : bool = false
-
Whether or not to fetch the rules for an edit (optional, default false)
Return values
array<string|int, mixed> —An array of input validation rules including:
- plugin_id The ID of the plugin
- event The event to register the callback under
- callback The public static callback to invoke when the event is triggered
- enabled Sets whether the action is enabled (1 to enable, 0 to disable)
getEventsByPlugin()
Retrieves all events that are registered for a particular plugin
private
getEventsByPlugin(int $plugin_id) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin
Return values
array<string|int, mixed> —An array of stdClass objects representing registered events
getMessagesPlugin()
Retrieves all message templates that are registered for a particular plugin
private
getMessagesPlugin(int $plugin_id) : array<string|int, mixed>
Parameters
- $plugin_id : int
-
The ID of the plugin
Return values
array<string|int, mixed> —An array of stdClass objects representing registered templates
getPluginInfo()
Fetch information about the given plugin object
private
getPluginInfo(object $plugin, int $company_id) : mixed
Parameters
- $plugin : object
-
The plugin object to fetch info on
- $company_id : int
-
The ID of the company to fetch the plugin info for
getTranslation()
Retrieves the translation of the given term, if one is set, otherwise the term itself
private
getTranslation(string $plugin_dir, string $term) : string
Parameters
- $plugin_dir : string
-
The directory name of the plugin to return results for
- $term : string
-
The language term from the plugin to translate
Return values
string —The translated term, if not empty, otherwise the given $term
invokePluginEvents()
Invokes the plugin event on all registered plugins
private
invokePluginEvents(array<string|int, mixed> $plugin_events, EventInterface $event) : EventInterface
Parameters
- $plugin_events : array<string|int, mixed>
-
An array of plugins that have registered events to be invoked
- $event : EventInterface
-
The event to process
Return values
EventInterface —The processed event object
loadPlugin()
Instantiates the given plugin and returns its instance
private
loadPlugin(string $dir) : An
Parameters
- $dir : string
-
The directory name of the plugin to load
Return values
An —instance of the plugin specified
setVersion()
Updates all installed plugins with the version given
private
setVersion(string $dir, string $version) : mixed
Parameters
- $dir : string
-
The directory name of the plugin to update
- $version : string
-
The version number to set for each plugin instance
translateArray()
Translates the given $values array for all matching $keys
private
translateArray(string $plugin_dir, array<string|int, mixed> $values, array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
- $plugin_dir : string
-
The directory name of the plugin to return results for
- $values : array<string|int, mixed>
-
An numerically-indexed array containing key/value pairs
- $keys : array<string|int, mixed>
-
An array of keys to to translate from the $values key/value paris
Return values
array<string|int, mixed> —The given $values are returned, with all matching value keys translated
translateCard()
Translates the names of language definitions within the card
private
translateCard(stdClass $card) : stdClass
Parameters
- $card : stdClass
-
The card whose language definitions to translate
Return values
stdClass —The stdClass $card translated