Any plugin that wants to add event observers to one of Piwik's {@hook # hooks},
or has special installation/uninstallation logic must implement this class.
Plugins that can specify everything they need to in the _plugin.json_ files,
such as themes, don't need to implement this class.
Class implementations should be named after the plugin they are a part of
(eg, class UserCountry extends Plugin).
### Plugin Metadata
In addition to providing a place for plugins to install/uninstall themselves
and add event observers, this class is also responsible for loading metadata
found in the plugin.json file.
The plugin.json file must exist in the root directory of a plugin. It can
contain the following information:
- **description**: An internationalized string description of what the plugin
does.
- **homepage**: The URL to the plugin's website.
- **authors**: A list of author arrays with keys for 'name', 'email' and 'homepage'
- **license**: The license the code uses (eg, GPL, MIT, etc.).
- **license_homepage**: URL to website describing the license used.
- **version**: The plugin version (eg, 1.0.1).
- **theme**: true or false. If true, the plugin will be treated as a theme.
### Examples
**How to extend**
use Piwik\Common;
use Piwik\Plugin;
use Piwik\Db;
class MyPlugin extends Plugin
{
public function getListHooksRegistered()
{
return array(
'API.getReportMetadata' => 'getReportMetadata',
'Another.event' => array(
'function' => 'myOtherPluginFunction',
'after' => true // executes this callback after others
)
);
}
public function install()
{
Db::exec("CREATE TABLE " . Common::prefixTable('mytable') . "...");
}
public function uninstall()
{
Db::exec("DROP TABLE IF EXISTS " . Common::prefixTable('mytable'));
}
public function getReportMetadata(&$metadata)
{
...
}
public function myOtherPluginFunction()
{
...
}
}