Piwik\Plugins\DevicePlugins\
The class defines the following methods:
__construct()
ash; Constructor. Inherited from Plugin
reloadPluginInformation()
Inherited from Plugin
getInformation()
ash; Returns plugin information, including: Inherited from Plugin
isPremiumFeature()
Inherited from Plugin
shouldLoadUmdOnDemand()
— Return true here if you want your plugin's Vue module to be loaded on demand, when it is first referenced, rather than on page load. Inherited from Plugin
registerEvents()
ash; Returns a list of events with associated event observers. Inherited from Plugin
postLoad()
ash; This method is executed after a plugin is loaded and translations are registered. Inherited from Plugin
requiresInternetConnection()
ash; 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 Inherited from Plugin
install()
ash; Installs the plugin. Inherited from Plugin
uninstall()
ash; Uninstalls the plugins. Inherited from Plugin
activate()
ash; Executed every time the plugin is enabled. Inherited from Plugin
deactivate()
ash; Executed every time the plugin is disabled. Inherited from Plugin
getVersion()
ash; Returns the plugin version number. Inherited from Plugin
isTheme()
ash; Returns true
if this plugin is a theme, false
if otherwise. Inherited from Plugin
getPluginName()
ash; Returns the plugin's base class name without the namespace, e.g., "UserCountry"
when the plugin class is "Piwik\Plugins\UserCountry\UserCountry"
. Inherited from Plugin
findComponent()
ash; Tries to find a component such as a Menu or Tasks within this plugin. Inherited from Plugin
findMultipleComponents()
Inherited from Plugin
hasMissingDependencies()
ash; Detect whether there are any missing dependencies. Inherited from Plugin
getMissingDependencies()
Inherited from Plugin
getMissingDependenciesAsString()
ash; Returns a string (translated) describing the missing requirements for this plugin and the given Matomo (formerly Piwik) version Inherited from Plugin
schedulePluginReArchiving()
ash; Schedules re-archiving of this plugin's reports from when this plugin was last deactivated to now. Inherited from Plugin
getPluginNameFromBacktrace()
ash; Extracts the plugin name from a backtrace array. Inherited from Plugin
getPluginNameFromNamespace()
ash; Extracts the plugin name from a namespace name or a fully qualified class name. Inherited from Plugin
getPluginLastActivationTime()
Inherited from Plugin
getPluginLastDeactivationTime()
Inherited from Plugin
getChanges()
ash; Get all changes for this plugin Inherited from Plugin
getAllDevicePluginsColumnClasses()
— Returns class names of all DevicePlugins Column classes.__construct()
Constructor.
$pluginName
(string
|bool
) —
A plugin name to force. If not supplied, it is set to the last part of the class name.Exception
— If plugin metadata is defined in both the getInformation() method
and the plugin.json file.reloadPluginInformation()
getInformation()
Returns plugin information, including:
array
value.isPremiumFeature()
shouldLoadUmdOnDemand()
Return true here if you want your plugin's Vue module to be loaded on demand, when it is first referenced, rather than on page load. This can be used to improve initial page load time, especially if your plugin includes a lot of Vue code.
Note: doing this means that any other plugins that depend on yours will no longer
be able to do a normal import ... from 'MyPlugin';
, they will instead have to
use the importPluginUmd()
function in CoreHome
which returns a Promise.
boolean
value.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.
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.
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
bool
value.install()
Installs the plugin. Derived classes should implement this class if the plugin needs to:
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.
Exception
— if uninstallation of fails for some reason.activate()
Executed every time the plugin is enabled.
deactivate()
Executed every time the plugin is disabled.
getVersion()
Returns the plugin version number.
string
value.isTheme()
Returns true
if this plugin is a theme, false
if otherwise.
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"
.
string
value.findComponent()
Tries to find a component such as a Menu or Tasks within this plugin.
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 Piwik\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()
It accepts the following parameter(s):
$directoryWithinPlugin
$expectedSubclass
It does not return anything or a mixed result.
hasMissingDependencies()
Detect whether there are any missing dependencies.
$piwikVersion
(null
) —
Defaults to the current Matomo versionbool
value.getMissingDependencies()
It accepts the following parameter(s):
$piwikVersion
It does not return anything or a mixed result.
getMissingDependenciesAsString()
Returns a string (translated) describing the missing requirements for this plugin and the given Matomo version
It accepts the following parameter(s):
$piwikVersion
(string
) —Returns: string
—
"AnonymousPiwikUsageMeasurement requires PIWIK >=3.0.0"
schedulePluginReArchiving()
Schedules re-archiving of this plugin's reports from when this plugin was last deactivated to now. If the last time core:archive was run is earlier than the plugin's last deactivation time, then we use that time instead.
Note: this only works for CLI archiving setups.
Note: the time frame is limited by the [General] rearchive_reports_in_past_last_n_months
INI config value.
Piwik\Exception\DI\DependencyException
Piwik\Exception\DI\NotFoundException
getPluginNameFromBacktrace()
Extracts the plugin name from a backtrace array. Returns false
if we can't find one.
It accepts the following parameter(s):
$backtrace
(array
) —
The result of debug_backtrace() or Exception::getTrace().Returns: string
|false
—
getPluginNameFromNamespace()
Extracts the plugin name from a namespace name or a fully qualified class name. Returns false
if we can't find one.
It accepts the following parameter(s):
$namespaceOrClassName
(string
) —
The namespace or class string.Returns: string
|false
—
getPluginLastActivationTime()
getPluginLastDeactivationTime()
getChanges()
Get all changes for this plugin
array
—
Array of changes
[{"title":"abc","description":"xyz","linkName":"def","link":"https://link","version":"1.2.3"}]getAllDevicePluginsColumnClasses()
Returns class names of all DevicePlugins Column classes.
string[]
value.