Class craft\base\Plugin
- Inheritance
- craft\base\Plugin » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
- Implements
- craft\base\PluginInterface, yii\base\Configurable
- Uses Traits
- craft\base\PluginTrait
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/base/Plugin.php
Plugin is the base class for classes representing plugins in terms of objects.
Property | Type | Description | Defined By |
---|---|---|---|
$changelogUrl |
string, null | The plugin’s changelog URL | craft\base\PluginTrait |
$controllerMap |
array | Mapping from controller ID to controller configurations. | yii\base\Module |
$controllerNamespace |
string | The namespace that controller classes are in. | yii\base\Module |
$defaultRoute |
string | The default route of this module. | yii\base\Module |
$description |
string, null | The plugin’s description | craft\base\PluginTrait |
$developer |
string, null | The plugin developer’s name | craft\base\PluginTrait |
$developerEmail |
string, null | The plugin developer’s support email | craft\base\PluginTrait |
$developerUrl |
string, null | The plugin developer’s website URL | craft\base\PluginTrait |
$documentationUrl |
string, null | The plugin’s documentation URL | craft\base\PluginTrait |
$downloadUrl |
string, null | The plugin’s download URL | craft\base\PluginTrait |
$hasCpSection |
boolean | Whether the plugin has its own section in the CP | craft\base\PluginTrait |
$hasCpSettings |
boolean | Whether the plugin has a settings page in the CP | craft\base\PluginTrait |
$id |
string | An ID that uniquely identifies this module among other modules which have the same parent. | yii\base\Module |
$isInstalled |
boolean | Whether the plugin is currently installed. | craft\base\PluginTrait |
$layout |
string, boolean | The layout that should be applied for views within this module. | yii\base\Module |
$minVersionRequired |
string | The minimum required version the plugin has to be so it can be updated. | craft\base\PluginTrait |
$module |
yii\base\Module | The parent module of this module. | yii\base\Module |
$name |
string, null | The plugin’s display name | craft\base\PluginTrait |
$packageName |
string, null | The plugin’s package name | craft\base\PluginTrait |
$params |
array | Custom module parameters (name => value). | yii\base\Module |
$schemaVersion |
string, null | The plugin’s schema version number | craft\base\PluginTrait |
$sourceLanguage |
string | The language that the plugin’s messages were written in | craft\base\PluginTrait |
$t9nCategory |
string, null | The translation category that this plugin’s translation messages should use. | craft\base\PluginTrait |
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | craft\base\Plugin |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
afterAction() |
This method is invoked right after an action within this module is executed. | yii\base\Module |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
beforeAction() |
This method is invoked right before an action within this module is executed. | yii\base\Module |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
clear() |
Removes the component from the locator. | yii\di\ServiceLocator |
createController() |
Creates a controller instance based on the given route. | yii\base\Module |
createControllerByID() |
Creates a controller based on the given controller ID. | yii\base\Module |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
get() |
{@inheritdoc} | yii\base\Module |
getBasePath() |
Returns the root directory of the module. | yii\base\Module |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getComponents() |
Returns the list of the component definitions or the loaded component instances. | yii\di\ServiceLocator |
getControllerPath() |
Returns the directory that contains the controller classes according to $controllerNamespace. | yii\base\Module |
getCpNavItem() |
Returns the CP nav item definition for this plugin’s CP section, if it has one. | craft\base\Plugin |
getHandle() |
Returns the plugin’s handle (really just an alias of yii\base\Module::$id). | craft\base\Plugin |
getInstance() |
Returns the currently requested instance of this module class. | yii\base\Module |
getLayoutPath() |
Returns the directory that contains layout view files for this module. | yii\base\Module |
getMigrator() |
Returns the plugin’s migration manager | craft\base\Plugin |
getModule() |
Retrieves the child module of the specified ID. | yii\base\Module |
getModules() |
Returns the sub-modules in this module. | yii\base\Module |
getSettings() |
Returns the model that the plugin’s settings should be stored on, if the plugin has settings. | craft\base\Plugin |
getSettingsResponse() |
Returns the settings page response. | craft\base\Plugin |
getUniqueId() |
Returns an ID that uniquely identifies this module among all modules within the current application. | yii\base\Module |
getVersion() |
Returns current module version. | yii\base\Module |
getViewPath() |
Returns the directory that contains the view files for this module. | yii\base\Module |
has() |
{@inheritdoc} | yii\base\Module |
hasEventHandlers() |
Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasModule() |
Checks whether the child module of the specified ID exists. | yii\base\Module |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
install() |
Installs the plugin. | craft\base\Plugin |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
runAction() |
Runs a controller action specified by a route. | yii\base\Module |
set() |
Registers a component definition with this locator. | yii\di\ServiceLocator |
setAliases() |
Defines path aliases. | yii\base\Module |
setBasePath() |
Sets the root directory of the module. | yii\base\Module |
setComponents() |
Registers a set of component definitions in this locator. | yii\di\ServiceLocator |
setInstance() |
Sets the currently requested instance of this module class. | yii\base\Module |
setLayoutPath() |
Sets the directory that contains the layout files. | yii\base\Module |
setModule() |
Adds a sub-module to this module. | yii\base\Module |
setModules() |
Registers sub-modules in the current module. | yii\base\Module |
setSettings() |
Sets the plugin settings | craft\base\Plugin |
setVersion() |
Sets current module version. | yii\base\Module |
setViewPath() |
Sets the directory that contains the view files. | yii\base\Module |
trigger() |
Triggers an event. | yii\base\Component |
uninstall() |
Uninstalls the plugin. | craft\base\Plugin |
Method | Description | Defined By |
---|---|---|
afterInstall() |
Performs actions after the plugin is installed. | craft\base\Plugin |
afterUninstall() |
Performs actions after the plugin is installed. | craft\base\Plugin |
beforeInstall() |
Performs actions before the plugin is installed. | craft\base\Plugin |
beforeUninstall() |
Performs actions before the plugin is installed. | craft\base\Plugin |
cpNavIconPath() |
Returns the path to the SVG icon that should be used in the plugin’s CP nav item. | craft\base\Plugin |
createInstallMigration() |
Instantiates and returns the plugin’s installation migration, if it has one. | craft\base\Plugin |
createSettingsModel() |
Creates and returns the model used to store the plugin’s settings. | craft\base\Plugin |
defaultVersion() |
Returns default module version. | yii\base\Module |
settingsHtml() |
Returns the rendered settings HTML, which will be inserted into the content block on the settings page. | craft\base\Plugin |
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_ACTION |
yii\base\ActionEvent | An event raised after executing a controller action. | yii\base\Module |
EVENT_BEFORE_ACTION |
yii\base\ActionEvent | An event raised before executing a controller action. | yii\base\Module |
Method Details
__construct()
public method
#
Constructor.
public void __construct ( $id, $parent = null, array $config = [] )
$id |
string | The ID of this module. |
$parent |
yii\base\Module | The parent module (if any). |
$config |
array | Name-value pairs that will be used to initialize the object properties. |
afterInstall()
protected method
#
Performs actions after the plugin is installed.
protected void afterInstall ( )
afterUninstall()
protected method
#
Performs actions after the plugin is installed.
protected void afterUninstall ( )
beforeInstall()
protected method
#
Performs actions before the plugin is installed.
protected boolean beforeInstall ( )
return | boolean | Whether the plugin should be installed |
---|
beforeUninstall()
protected method
#
Performs actions before the plugin is installed.
protected boolean beforeUninstall ( )
return | boolean | Whether the plugin should be installed |
---|
cpNavIconPath()
protected method
#
Returns the path to the SVG icon that should be used in the plugin’s CP nav item.
See also getCpNavItem().
protected string, null cpNavIconPath ( )
createInstallMigration()
protected method
#
Instantiates and returns the plugin’s installation migration, if it has one.
protected craft\db\Migration, null createInstallMigration ( )
return | craft\db\Migration, null | The plugin’s installation migration |
---|
createSettingsModel()
protected method
#
Creates and returns the model used to store the plugin’s settings.
protected craft\base\Model, null createSettingsModel ( )
getCpNavItem()
public method
#
Returns the CP nav item definition for this plugin’s CP section, if it has one.
public array, null getCpNavItem ( )
getHandle()
public method
#
Returns the plugin’s handle (really just an alias of yii\base\Module::$id).
public string getHandle ( )
return | string | The plugin’s handle |
---|
getMigrator()
public method
#
Returns the plugin’s migration manager
public craft\db\MigrationManager getMigrator ( )
return | craft\db\MigrationManager | The plugin’s migration manager |
---|
getSettings()
public method
#
Returns the model that the plugin’s settings should be stored on, if the plugin has settings.
public craft\base\Model, null getSettings ( )
return | craft\base\Model, null | The model that the plugin’s settings should be stored on, if the plugin has settings |
---|
getSettingsResponse()
public method
#
Returns the settings page response.
public mixed getSettingsResponse ( )
return | mixed | The result that should be returned from craft\controllers\PluginsController::actionEditPluginSettings() |
---|
install()
public method
#
Installs the plugin.
public void, false install ( )
return | void, false | Return false to indicate the installation failed.
All other return values mean the installation was successful.
|
---|
setSettings()
public method
#
Sets the plugin settings
public void setSettings ( array $settings )
$settings |
array | The plugin settings that should be set on the settings model |
settingsHtml()
protected method
#
Returns the rendered settings HTML, which will be inserted into the content block on the settings page.
protected string, null settingsHtml ( )
return | string, null | The rendered settings HTML |
---|
uninstall()
public method
#
Uninstalls the plugin.
public void, false uninstall ( )
return | void, false | Return false to indicate the uninstallation failed.
All other return values mean the uninstallation was successful.
|
---|