Piwik\Plugins\DevicePlugins\

DevicePlugins

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):
    • $pluginName (string|bool) — A plugin name to force. If not supplied, it is set to the last part of the class name.
  • It throws one of the following exceptions:
    • Exception — If plugin metadata is defined in both the getInformation() method and the plugin.json file.

reloadPluginInformation()

Signature

  • It does not return anything.

getInformation()

Returns plugin information, including:

  • 'description' => string // 1-2 sentence description of the plugin
  • 'author' => string // plugin author
  • 'author_homepage' => string // author homepage URL (or email "mailto:youremail@example.org")
  • 'homepage' => string // plugin homepage URL
  • 'license' => string // plugin license
  • 'version' => string // plugin version number; examples and 3rd party plugins must not use Version::VERSION; 3rd party plugins must increment the version number with each plugin release
  • 'theme' => bool // Whether this plugin is a theme (a theme is a plugin, but a plugin is not necessarily a theme)

Signature

  • It returns a array value.

isPremiumFeature()

Signature

  • It is a finalized method.
  • It does not return anything.

registerEvents()

Since Matomo 2.15.0

Returns a list of events with associated event observers.

Derived classes should use this method to associate callbacks with events.

Signature

  • Returns: array — eg, array( 'API.getReportMetadata' => 'myPluginFunction', 'Another.event' => array( 'function' => 'myOtherPluginFunction', 'after' => true // execute after callbacks w/o ordering ) 'Yet.Another.event' => array( 'function' => 'myOtherPluginFunction', 'before' => true // execute before callbacks w/o ordering ) )

postLoad()

This method is executed after a plugin is loaded and translations are registered.

Useful for initialization code that uses translated strings.

Signature

  • It does not return anything.

requiresInternetConnection()

Defines whether the whole plugin requires a working internet connection If set to true, the plugin will be automatically unloaded if enable_internet_features is 0, even if the plugin is activated

Signature

  • It returns a bool value.

install()

Installs the plugin.

Derived classes should implement this class if the plugin needs to:

  • create tables
  • update existing tables
  • etc.

Signature

  • It does not return anything.
  • It throws one of the following exceptions:
    • Exception — if installation of fails for some reason.

uninstall()

Uninstalls the plugins.

Derived classes should implement this method if the changes made in install() need to be undone during uninstallation.

In most cases, if you have an install() method, you should provide an uninstall() method.

Signature

  • It does not return anything.
  • It throws one of the following exceptions:
    • Exception — if uninstallation of fails for some reason.

activate()

Executed every time the plugin is enabled.

Signature

  • It does not return anything.

deactivate()

Executed every time the plugin is disabled.

Signature

  • It does not return anything.

getVersion()

Returns the plugin version number.

Signature

  • It is a finalized method.
  • It returns a string value.

isTheme()

Returns true if this plugin is a theme, false if otherwise.

Signature

  • It returns a bool value.

getPluginName()

Returns the plugin's base class name without the namespace, e.g., "UserCountry" when the plugin class is "Piwik\Plugins\UserCountry\UserCountry".

Signature

  • It is a finalized method.
  • It returns a string value.

findComponent()

Tries to find a component such as a Menu or Tasks within this plugin.

Signature

  • It accepts the following parameter(s):

    • $componentName (string) — The name of the component you want to look for. In case you request a component named 'Menu' it'll look for a file named 'Menu.php' within the root of the plugin folder that implements a class named Matomo\Plugin\$PluginName\Menu . If such a file exists but does not implement this class it'll silently ignored.
    • $expectedSubclass (string) — If not empty, a check will be performed whether a found file extends the given subclass. If the requested file exists but does not extend this class a warning will be shown to advice a developer to extend this certain class.
  • Returns: string|null — Null if the requested component does not exist or an instance of the found component.

findMultipleComponents()

Signature

  • It accepts the following parameter(s):

    • $directoryWithinPlugin

    • $expectedSubclass

  • It does not return anything.

hasMissingDependencies()

Detect whether there are any missing dependencies.

Signature

  • It accepts the following parameter(s):
    • $piwikVersion (null) — Defaults to the current Matomo version
  • It returns a bool value.

getMissingDependencies()

Signature

  • It accepts the following parameter(s):

    • $piwikVersion
  • It does not return anything.

getMissingDependenciesAsString()

Returns a string (translated) describing the missing requirements for this plugin and the given Matomo version

Signature

  • It accepts the following parameter(s):

    • $piwikVersion (string) —
  • Returns: string — "AnonymousPiwikUsageMeasurement requires PIWIK >=3.0.0"

getPluginNameFromBacktrace()

Extracts the plugin name from a backtrace array.

Returns false if we can't find one.

Signature

getPluginNameFromNamespace()

Extracts the plugin name from a namespace name or a fully qualified class name.

Returns false if we can't find one.

Signature

  • It accepts the following parameter(s):

    • $namespaceOrClassName (string) — The namespace or class string.
  • Returns: string|Piwik\false

getAllDevicePluginsColumnClasses()

Returns class names of all DevicePlugins Column classes.

Signature

  • It returns a string[] value.