IPlugin

Type
Interface
Namespace
Craft
Extends
Craft\ISavableComponentType
Implemented by
Craft\BasePlugin
Since
2.1

Interface IPlugin

See also http://craftcms.com

View source (opens new window)

# Public Methods

Method Description
createTables() Creates any tables defined by the plugin’s records.
dropTables() Drops any tables defined by the plugin’s records.
getClassHandle() Returns the component’s handle, ideally based on the class name.
getDescription() Returns the plugin’s description.
getDeveloper() Returns the plugin developer’s name.
getDeveloperUrl() Returns the plugin developer’s URL.
getDocumentationUrl() Returns the plugin documentation’s URL.
getName() Returns the component’s name.
getRecords() Returns the record classes provided by this plugin.
getReleaseFeedUrl() Returns the plugin’s releases JSON feed URL.
getSchemaVersion() Returns the plugin’s schema version number.
getSettings() Returns the component’s settings model.
getSettingsHtml() Returns the component’s settings HTML.
getSettingsUrl() Returns the URL to the plugin’s settings page in the CP.
getSourceLanguage() Returns the locale ID that identifies what language the plugin was written in.
getVersion() Returns the plugin’s version number.
hasCpSection() Returns whether this plugin has its own section in the CP.
hasSettings() Returns whether the plugin has settings.
isSelectable() Returns whether this component should be shown when the user is creating a component of this type.
onAfterInstall() Performs any actions that should occur after the plugin is installed.
onBeforeInstall() Performs any actions that should occur before the plugin is installed.
onBeforeUninstall() Performs any actions that should occur before the plugin is uninstalled.
prepSettings() Preps the settings before they’re saved to the database.
setSettings() Sets the setting values.

# createTables()

Creates any tables defined by the plugin’s records.

View source (opens new window)

Returns

void

Signature

public abstract void createTables ( )

# dropTables()

Drops any tables defined by the plugin’s records.

View source (opens new window)

Returns

void

Signature

public abstract void dropTables ( )

# getDescription()

Returns the plugin’s description.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The plugin’s description.

Signature

public abstract string, null getDescription ( )

# getDeveloper()

Returns the plugin developer’s name.

View source (opens new window)

Returns

string (opens new window) – The plugin developer’s name.

Signature

public abstract string getDeveloper ( )

# getDeveloperUrl()

Returns the plugin developer’s URL.

View source (opens new window)

Returns

string (opens new window) – The plugin developer’s URL.

Signature

public abstract string getDeveloperUrl ( )

# getDocumentationUrl()

Returns the plugin documentation’s URL.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The plugin documentation’s URL.

Signature

public abstract string, null getDocumentationUrl ( )

# getRecords()

Returns the record classes provided by this plugin.

View source (opens new window)

Arguments

Returns

Craft\BaseRecord[]

Signature

public abstract Craft\BaseRecord[] getRecords ( $scenario = null )

# getReleaseFeedUrl()

Returns the plugin’s releases JSON feed URL. If the plugin wants to have its updates included in the Updates page, it should provide a JSON feed in the following format:

[
    {
        "version": "0.9.0",
        "downloadUrl": "https://download.craftcommerce.com/0.9/Commerce0.9.0.zip",
        "date": "2015-12-01T10:00:00-08:00",
        "notes": [
            "# Big Stuff",
            "[Added] It’s now possible to create new products right from Product Selector Modals (like the ones used by Products fields).",
            "[Improved] Variants are now defined in a new Variant Matrix field, right on the main Edit Product pages.",
            "# Bug Fixes",
            "[Fixed] Fixed a Twig error that occurred if you manually went to /commerce/orders/new. You now receive a 404 error instead."
        ]
    },
    {
        "version": "0.9.1",
        "downloadUrl": "https://download.craftcommerce.com/0.9/Commerce0.9.1.zip",
        "date": "2015-12-01T11:00:00-08:00",
        "notes": [
            "[Fixed] Fixed a PHP error that occurred when creating a new produt when the current user’s username was ‘null’."
        ]
    }
]

Notes:

  • The feed must be valid JSON.
  • The feed’s URL must begin with “https://” (so it is fetched over SSL).
  • Each release must contain version, downloadUrl, date, and notes attributes.
  • Each release’s downloadUrl must begin with “https://” (so it is downloaded over SSL).
  • Each release’s date must be an ISO-8601-formatted date, as defined by either {@link http://php.net/manual/en/class.datetime.php#datetime.constants.atom DateTime::ATOM} or {@link http://php.net/manual/en/class.datetime.php#datetime.constants.iso8601 DateTime::ISO8601} (with or without the colon between the hours and minutes of the timezone offset).
  • notes can either be a string (with each release note separated by a newline character), or an array.
  • Release note lines that begin with # will be treated as headings.
  • Release note lines that begin with [Added], [Improved], or [Fixed] will be given added, improved, and fixed classes within the Updates page.
  • Release note lines can contain Markdown code, but not HTML.
  • Releases can contain a critical attribute which can be set to true if the release is critical.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The plugin’s release feed URL

Signature

public abstract string, null getReleaseFeedUrl ( )

# getSchemaVersion()

Returns the plugin’s schema version number. Changing the schema version number tells Craft that there are new migration files that need to be run.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The plugin’s version number, or null if it doesn’t need one

Signature

public abstract string, null getSchemaVersion ( )

# getSettingsUrl()

Returns the URL to the plugin’s settings page in the CP. If your plugin requires a custom settings page, you can use this method to point to it.

If this method returns anything, it will be run through {@link UrlHelper::getCpUrl()} before getting output, so a full URL is not necessary.

If this method doesn’t return anything, a simple settings page will be provided for your plugin, filled with whatever {@link getSettingsHtml()} returns.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The URL to the plugin’s settings page, if it has a custom one.

Signature

public abstract string, null getSettingsUrl ( )

# getSourceLanguage()

Returns the locale ID that identifies what language the plugin was written in.

View source (opens new window)

Returns

string (opens new window) – The plugin’s source language.

Signature

public abstract string getSourceLanguage ( )

# getVersion()

Returns the plugin’s version number.

View source (opens new window)

Returns

string (opens new window) – The plugin’s version number.

Signature

public abstract string getVersion ( )

# hasCpSection()

Returns whether this plugin has its own section in the CP.

View source (opens new window)

Returns

boolean (opens new window) – Whether this plugin has its own section in the CP.

Signature

public abstract boolean hasCpSection ( )

# hasSettings()

Returns whether the plugin has settings.

View source (opens new window)

Returns

boolean (opens new window) – Whether the plugin has settings

Signature

public abstract boolean hasSettings ( )

# onAfterInstall()

Performs any actions that should occur after the plugin is installed.

View source (opens new window)

Returns

void

Signature

public abstract void onAfterInstall ( )

# onBeforeInstall()

Performs any actions that should occur before the plugin is installed.

View source (opens new window)

Returns

void, false (opens new window) – Return false to abort plugin installation

Signature

public abstract void, false onBeforeInstall ( )

# onBeforeUninstall()

Performs any actions that should occur before the plugin is uninstalled.

View source (opens new window)

Returns

void

Signature

public abstract void onBeforeUninstall ( )