Blesta Source Documentation

Plugin

AbstractYes

Abstract class that all Plugin handlers extend

Defines all methods plugin handlers must inherit and provides all methods common between all plugin handlers

Attributes
#[AllowDynamicProperties]
Table of Contents

Properties

$config
$messages

Methods

allowsServiceTabs() Returns whether this plugin provides support for setting admin or client service tabs
cron() Runs the cron task identified by the key used to create the cron task
errors() Return all validation errors encountered
getActions() Returns all actions to be configured for this widget (invoked after install() or upgrade(), overwrites all existing actions)
getAdminServiceTabs() Returns all tabs to display to an admin when managing a service
getAuthors() Returns the name and URL for the authors of this plugin
getCards() Returns all cards to be configured for this plugin (invoked after install() or upgrade(), overwrites all existing cards)
getClientServiceTabs() Returns all tabs to display to a client when managing a service
getDescription() Returns the description of this plugin
getEvents() Returns all events to be registered for this plugin (invoked after install() or upgrade(), overwrites all existing events)
getLogo() Returns the relative path from this plugin's directory to the logo for this plugin. Defaults to views/default/images/logo.png
getMessages() Retrieves a set of messages set by the module
getMessageTemplates() Returns all messages to be configured for this plugin (invoked after install() or upgrade(), overwrites all existing messages)
getName() Returns the name of this plugin
getPermissionGroups() Returns all permission groups to be configured for this plugin (invoked after install(), upgrade(), and uninstall(), overwrites all existing permission groups)
getPermissions() Returns all permissions to be configured for this plugin (invoked after install(), upgrade(), and uninstall(), overwrites all existing permissions)
getVersion() Returns the version of this plugin
install() Performs any necessary bootstraping actions
uninstall() Performs any necessary cleanup actions
upgrade() Performs migration of data from $current_version (the current installed version) to the given file set version
loadConfig() Loads a given config file
setMessage() Sets a message
translate() Translate the given str, or passthrough if no translation et
Properties

$config

protected stdClass $config

A stdClass object representing the configuration for this plugin

$messages

private array<string|int, mixed> $messages = []

An array of messages keyed by type (e.g. ['success' => ['message' => ['Message 1', 'Message 2']]])

Methods

allowsServiceTabs()

Returns whether this plugin provides support for setting admin or client service tabs

public allowsServiceTabs() : bool
Tags
see
Plugin::getAdminServiceTabs
see
Plugin::getClientServiceTabs
Return values
bool

True if the plugin supports service tabs, or false otherwise

cron()

Runs the cron task identified by the key used to create the cron task

public cron(string $key) : array<string|int, mixed>
Parameters
$key : string

The key used to create the cron task

Tags
see
CronTasks::add()
Return values
array<string|int, mixed>

An array containing the log lines to be displayed when executing the cron task

errors()

Return all validation errors encountered

public errors() : mixed
Return values
mixed

Boolean false if no errors encountered, an array of errors otherwise

getActions()

Returns all actions to be configured for this widget (invoked after install() or upgrade(), overwrites all existing actions)

public getActions() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • action The action to register for
  • uri The URI to be invoked for the given action
  • name The name to represent the action (can be language definition)
  • options An array of key/value pair options for the given action

getAdminServiceTabs()

Returns all tabs to display to an admin when managing a service

public getAdminServiceTabs(stdClass $service) : array<string|int, mixed>
Parameters
$service : stdClass

An stdClass object representing the selected service

Return values
array<string|int, mixed>

An array of tabs in the format of method => array where array contains:

  • name (required) The name of the link
  • href (optional) use to link to a different URL Example: array('methodName' => "Title", 'methodName2' => "Title2") array('methodName' => array('name' => "Title", 'href' => "https://blesta.com"))

getAuthors()

Returns the name and URL for the authors of this plugin

public getAuthors() : array<string|int, mixed>
Return values
array<string|int, mixed>

The name and URL of the authors of this plugin

getCards()

Returns all cards to be configured for this plugin (invoked after install() or upgrade(), overwrites all existing cards)

public getCards() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • level The level this card should be displayed on (client or staff) (optional, default client)
  • callback An array containing the class name and 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)
  • 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)

getClientServiceTabs()

Returns all tabs to display to a client when managing a service

public getClientServiceTabs(stdClass $service) : array<string|int, mixed>
Parameters
$service : stdClass

A stdClass object representing the selected package

Return values
array<string|int, mixed>

An array of tabs in the format of method => array where array contains:

  • name (required) The name of the link
  • icon (optional) use to display a custom icon
  • href (optional) use to link to a different URL Example: array('methodName' => "Title", 'methodName2' => "Title2") array('methodName' => array('name' => "Title", 'icon' => "icon"))

getDescription()

Returns the description of this plugin

public getDescription() : string
Return values
string

The description of this plugin

getEvents()

Returns all events to be registered for this plugin (invoked after install() or upgrade(), overwrites all existing events)

public getEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • event The event to register for
  • callback A string or array representing a callback function or class/method. If a user (e.g. non-native PHP) function or class/method, the plugin must automatically define it when the plugin is loaded. To invoke an instance methods pass "this" instead of the class name as the 1st callback element.

Returns the relative path from this plugin's directory to the logo for this plugin. Defaults to views/default/images/logo.png

public getLogo() : string
Return values
string

The relative path to the plugin's logo

getMessages()

Retrieves a set of messages set by the module

public final getMessages() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of messages

getMessageTemplates()

Returns all messages to be configured for this plugin (invoked after install() or upgrade(), overwrites all existing messages)

public getMessageTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • 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 ()

getName()

Returns the name of this plugin

public getName() : string
Return values
string

The common name of this plugin

getPermissionGroups()

Returns all permission groups to be configured for this plugin (invoked after install(), upgrade(), and uninstall(), overwrites all existing permission groups)

public getPermissionGroups() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • 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)

getPermissions()

Returns all permissions to be configured for this plugin (invoked after install(), upgrade(), and uninstall(), overwrites all existing permissions)

public getPermissions() : array<string|int, mixed>
Return values
array<string|int, mixed>

A numerically indexed array containing:

  • 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)

getVersion()

Returns the version of this plugin

public getVersion() : string
Return values
string

The current version of this plugin

install()

Performs any necessary bootstraping actions

public install(int $plugin_id) : mixed
Parameters
$plugin_id : int

The ID of the plugin being installed

uninstall()

Performs any necessary cleanup actions

public uninstall(int $plugin_id, bool $last_instance) : mixed
Parameters
$plugin_id : int

The ID of the plugin being uninstalled

$last_instance : bool

True if $plugin_id is the last instance across all companies for this plugin, false otherwise

upgrade()

Performs migration of data from $current_version (the current installed version) to the given file set version

public upgrade(string $current_version, int $plugin_id) : mixed
Parameters
$current_version : string

The current installed version of this plugin

$plugin_id : int

The ID of plugin being upgraded

loadConfig()

Loads a given config file

protected loadConfig(string $file) : mixed
Parameters
$file : string

The full path to the config file to load

setMessage()

Sets a message

protected final setMessage(string $type, string $message) : mixed
Parameters
$type : string

The type of message ('success', 'error", or 'notice')

$message : string

The message text to display

translate()

Translate the given str, or passthrough if no translation et

private translate(string $str) : string
Parameters
$str : string

The string to translate

Return values
string

The translated string

Tags
subpackage

components.plugins

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results