PHP Class piwik\plugin\Manager

Inheritance: extends Piwik\Singleton
Show file Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$doLoadAlwaysActivatedPlugins
$doLoadPlugins
$loadedPlugins Piwik\Plugin[]
$pluginToAlwaysActivate These are always activated and cannot be deactivated
$pluginsToLoad

Public Methods

Method Description
__construct ( Piwik\Application\Kernel\PluginList $pluginList )
activatePlugin ( string $pluginName ) Activate the specified plugin and install (if needed)
addLoadedPlugin ( string $pluginName, Plugin $newPlugin ) Add a plugin in the loaded plugins array
checkIsPluginActivated ( string $pluginName ) Checks whether the given plugin is activated, if not triggers an exception.
clearPluginsInstalledConfig ( )
deactivatePlugin ( string $pluginName ) Deactivate plugin
deletePluginFromFilesystem ( $plugin )
doNotLoadAlwaysActivatedPlugins ( ) Disable loading of "always activated" plugins.
doNotLoadPlugins ( ) Disable plugin loading.
findComponents ( string $componentName, string $expectedSubclass ) : stdClass[] Tries to find the given components such as a Menu or Tasks implemented by plugins.
findMultipleComponents ( $directoryWithinPlugin, $expectedSubclass )
getActivatedPlugins ( ) : string[] Returns a list of all names of currently activated plugin eg,
getActivatedPluginsFromConfig ( )
getAllPluginsNames ( ) : array Returns the name of all plugins found in this Piwik instance (including those not enabled and themes)
getIgnoredBogusPlugins ( )
getIncompatiblePlugins ( string $piwikVersion ) : Plugin[]
getInstalledPluginsName ( ) : array Return names of all installed plugins.
getInstance ( ) : self
getLoadedPlugin ( string $name ) : Plugin Returns a Plugin object by name.
getLoadedPlugins ( ) : Plugin[] Returns an array mapping loaded plugin names with their plugin objects, eg,
getLoadedPluginsName ( ) : array Returns an array containing the plugins class names (eg. 'UserCountry' and NOT 'UserCountry')
getMissingPlugins ( ) : array Returns names of plugins that should be loaded, but cannot be since their files cannot be found.
getNumberOfActivatedPlugins ( )
getPluginsDirectory ( )
getPluginsLoadedAndActivated ( ) : Plugin[] Returns an array of plugins that are currently loaded and activated, mapping loaded plugin names with their plugin objects, eg,
getTheme ( string $themeName ) : Piwik\Theme
getThemeEnabled ( ) : Plugin Returns the currently enabled theme.
getTrackerPluginsNotToLoad ( ) : array Get list of plugins to not load
installLoadedPlugins ( ) : array Install loaded plugins
isPluginActivated ( string $name ) : boolean Returns true if a plugin has been activated.
isPluginBundledWithCore ( string $name ) : boolean Returns true if the plugin is bundled with core or false if it is third party.
isPluginInstalled ( $pluginName ) : boolean
isPluginLoaded ( string $name ) : boolean Returns true if plugin is loaded (in memory).
isPluginOfficialAndNotBundledWithCore ( $pluginName ) : boolean
isPluginThirdPartyAndBogus ( $pluginName ) : boolean
isTrackerPlugin ( Plugin $plugin )
isValidPluginName ( $pluginName )
loadActivatedPlugins ( ) Loads plugin that are enabled
loadAllPluginsAndGetTheirInfo ( ) : array Returns info regarding all plugins. Loads plugins that can be loaded.
loadCorePluginsDuringTracker ( ) Called during Tracker
loadPlugin ( string $pluginName ) : Plugin | null Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry.
loadPluginTranslations ( )
loadPlugins ( array $pluginsToLoad ) Load AND activates the specified plugins. It will also overwrite all previously loaded plugins, so it acts as a setter.
loadTrackerPlugins ( ) : array
postLoadPlugins ( ) Execute postLoad() hook for loaded plugins
readPluginsDirectory ( ) : array Reads the directories inside the plugins/ directory and returns their names in an array
setTrackerPluginsNotToLoad ( array $plugins ) Do not load the specified plugins (used during testing, to disable Provider plugin)
uninstallPlugin ( $pluginName ) : boolean Uninstalls a Plugin (deletes plugin files from the disk) Only deactivated plugins can be uninstalled
unloadPlugin ( Plugin | string $plugin ) Unload plugin
unloadPlugins ( ) Unload all loaded plugins

Protected Methods

Method Description
getClassNamePlugin ( $pluginName )
getPluginsFromGlobalIniConfigFile ( ) : array Reading the plugins from the global.ini.php config file
isManifestFileFound ( $path )
isPluginEnabledByDefault ( $name ) : boolean
isPluginInFilesystem ( $pluginName )
makePluginClass ( $pluginName ) : Plugin

Private Methods

Method Description
clearCache ( string $pluginName )
deactivateThemeIfTheme ( $pluginName )
doesAnotherPluginDefineSameColumnWithDbEntry ( Piwik\Plugin\Dimension\VisitDimension | Piwik\Plugin\Dimension\ActionDimension | Piwik\Plugin\Dimension\ConversionDimension $dimension, Piwik\Plugin\Dimension\VisitDimension[] | Piwik\Plugin\Dimension\ActionDimension[] | Piwik\Plugin\Dimension\ConversionDimension[] $allDimensions ) : boolean
executePluginDeactivate ( $pluginName )
executePluginInstall ( Plugin $plugin ) Install a specific plugin
executePluginUninstall ( $pluginName )
installPluginIfNecessary ( Plugin $plugin ) Install a plugin, if necessary
isPluginAlwaysActivated ( string $name ) : boolean Returns true if plugin is always activated
isPluginBogus ( $pluginName ) : boolean
isPluginUninstallable ( $name ) : boolean Returns true if the plugin can be uninstalled. Any non-core plugin can be uninstalled.
makePluginsToLoad ( array $pluginsToLoad ) : array
makeSureOnlyActivatedPluginsAreLoaded ( )
pluginStructureLooksValid ( $path )
reloadActivatedPlugins ( ) Load the plugins classes installed.
removeInstalledVersionFromOptionTable ( $name )
removePluginFromConfig ( $pluginName )
removePluginFromPluginsConfig ( $pluginName )
removePluginFromPluginsInstalledConfig ( $pluginName )
resetTransientCache ( )
uninstallDimension ( string $prefix, Dimension $dimension, Piwik\Plugin\Dimension\VisitDimension[] | Piwik\Plugin\Dimension\ActionDimension[] | Piwik\Plugin\Dimension\ConversionDimension[] $allDimensions )
unloadPluginFromMemory ( $pluginName )
updatePluginsConfig ( array $pluginsToLoad ) Update Plugins config
updatePluginsInstalledConfig ( array $plugins ) Update PluginsInstalled config

Method Details

__construct() public method

public __construct ( Piwik\Application\Kernel\PluginList $pluginList )
$pluginList Piwik\Application\Kernel\PluginList

activatePlugin() public method

Activate the specified plugin and install (if needed)
public activatePlugin ( string $pluginName )
$pluginName string Name of plugin

addLoadedPlugin() public method

Add a plugin in the loaded plugins array
public addLoadedPlugin ( string $pluginName, Plugin $newPlugin )
$pluginName string plugin name without prefix (eg. 'UserCountry')
$newPlugin Piwik\Plugin

checkIsPluginActivated() public method

Checks whether the given plugin is activated, if not triggers an exception.
public checkIsPluginActivated ( string $pluginName )
$pluginName string

clearPluginsInstalledConfig() public method

deactivatePlugin() public method

Deactivate plugin
public deactivatePlugin ( string $pluginName )
$pluginName string Name of plugin

deletePluginFromFilesystem() public static method

public static deletePluginFromFilesystem ( $plugin )

doNotLoadAlwaysActivatedPlugins() public method

Disable loading of "always activated" plugins.

doNotLoadPlugins() public method

Disable plugin loading.
public doNotLoadPlugins ( )

findComponents() public method

This method won't cache the found components. If you need to find the same component multiple times you might want to cache the result to save a tiny bit of time.
public findComponents ( string $componentName, string $expectedSubclass ) : stdClass[]
$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 all plugin folders that implement a class named Piwik\Plugin\$PluginName\Menu.
$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.
return stdClass[]

findMultipleComponents() public method

public findMultipleComponents ( $directoryWithinPlugin, $expectedSubclass )

getActivatedPlugins() public method

array( 'UserCountry' 'UserLanguage' );
public getActivatedPlugins ( ) : string[]
return string[]

getActivatedPluginsFromConfig() public method

getAllPluginsNames() public static method

Returns the name of all plugins found in this Piwik instance (including those not enabled and themes)
public static getAllPluginsNames ( ) : array
return array

getClassNamePlugin() protected method

protected getClassNamePlugin ( $pluginName )

getIgnoredBogusPlugins() public method

getIncompatiblePlugins() public method

public getIncompatiblePlugins ( string $piwikVersion ) : Plugin[]
$piwikVersion string
return Piwik\Plugin[]

getInstalledPluginsName() public method

Return names of all installed plugins.
public getInstalledPluginsName ( ) : array
return array

getInstance() public static method

public static getInstance ( ) : self
return self

getLoadedPlugin() public method

Returns a Plugin object by name.
public getLoadedPlugin ( string $name ) : Plugin
$name string The name of the plugin, eg, `'Actions'`.
return Piwik\Plugin

getLoadedPlugins() public method

array( 'UserCountry' => Plugin $pluginObject, 'UserLanguage' => Plugin $pluginObject, );
public getLoadedPlugins ( ) : Plugin[]
return Piwik\Plugin[]

getLoadedPluginsName() public method

Returns an array containing the plugins class names (eg. 'UserCountry' and NOT 'UserCountry')
public getLoadedPluginsName ( ) : array
return array

getMissingPlugins() public method

Returns names of plugins that should be loaded, but cannot be since their files cannot be found.
public getMissingPlugins ( ) : array
return array

getNumberOfActivatedPlugins() public method

getPluginsDirectory() public static method

public static getPluginsDirectory ( )

getPluginsFromGlobalIniConfigFile() protected method

Reading the plugins from the global.ini.php config file

getPluginsLoadedAndActivated() public method

array( 'UserCountry' => Plugin $pluginObject, 'UserLanguage' => Plugin $pluginObject, );
public getPluginsLoadedAndActivated ( ) : Plugin[]
return Piwik\Plugin[]

getTheme() public method

public getTheme ( string $themeName ) : Piwik\Theme
$themeName string
return Piwik\Theme

getThemeEnabled() public method

If no theme is enabled, the **Morpheus** plugin is returned (this is the base and default theme).
public getThemeEnabled ( ) : Plugin
return Piwik\Plugin

getTrackerPluginsNotToLoad() public method

Get list of plugins to not load
public getTrackerPluginsNotToLoad ( ) : array
return array

installLoadedPlugins() public method

Install loaded plugins
public installLoadedPlugins ( ) : array
return array Error messages of plugin install fails

isManifestFileFound() protected static method

protected static isManifestFileFound ( $path )

isPluginActivated() public method

Returns true if a plugin has been activated.
public isPluginActivated ( string $name ) : boolean
$name string Name of plugin, eg, `'Actions'`.
return boolean

isPluginBundledWithCore() public method

Returns true if the plugin is bundled with core or false if it is third party.
public isPluginBundledWithCore ( string $name ) : boolean
$name string The name of the plugin, eg, `'Actions'`.
return boolean

isPluginEnabledByDefault() protected method

protected isPluginEnabledByDefault ( $name ) : boolean
$name
return boolean

isPluginInFilesystem() protected method

protected isPluginInFilesystem ( $pluginName )

isPluginInstalled() public method

public isPluginInstalled ( $pluginName ) : boolean
$pluginName
return boolean

isPluginLoaded() public method

Returns true if plugin is loaded (in memory).
public isPluginLoaded ( string $name ) : boolean
$name string Name of plugin, eg, `'Acions'`.
return boolean

isPluginOfficialAndNotBundledWithCore() public method

public isPluginOfficialAndNotBundledWithCore ( $pluginName ) : boolean
$pluginName
return boolean

isPluginThirdPartyAndBogus() public method

public isPluginThirdPartyAndBogus ( $pluginName ) : boolean
$pluginName
return boolean

isTrackerPlugin() public method

public isTrackerPlugin ( Plugin $plugin )
$plugin Piwik\Plugin

isValidPluginName() public method

public isValidPluginName ( $pluginName )

loadActivatedPlugins() public method

Loads plugin that are enabled

loadAllPluginsAndGetTheirInfo() public method

Returns info regarding all plugins. Loads plugins that can be loaded.
public loadAllPluginsAndGetTheirInfo ( ) : array
return array An array that maps plugin names with arrays of plugin information. Plugin information consists of the following entries: - **activated**: Whether the plugin is activated. - **alwaysActivated**: Whether the plugin should always be activated, or not. - **uninstallable**: Whether the plugin is uninstallable or not. - **invalid**: If the plugin is invalid, this property will be set to true. If the plugin is not invalid, this property will not exist. - **info**: If the plugin was loaded, will hold the plugin information. See {@link Piwik\Plugin::getInformation()}.

loadCorePluginsDuringTracker() public method

Called during Tracker

loadPlugin() public method

Contrary to loadPlugins() it does not activate the plugin, it only loads it.
public loadPlugin ( string $pluginName ) : Plugin | null
$pluginName string
return Piwik\Plugin | null

loadPluginTranslations() public method

loadPlugins() public method

Load AND activates the specified plugins. It will also overwrite all previously loaded plugins, so it acts as a setter.
public loadPlugins ( array $pluginsToLoad )
$pluginsToLoad array Array of plugins to load.

loadTrackerPlugins() public method

public loadTrackerPlugins ( ) : array
return array names of plugins that have been loaded

makePluginClass() protected method

protected makePluginClass ( $pluginName ) : Plugin
$pluginName
return Piwik\Plugin

postLoadPlugins() public method

Execute postLoad() hook for loaded plugins
public postLoadPlugins ( )

readPluginsDirectory() public method

Reads the directories inside the plugins/ directory and returns their names in an array
public readPluginsDirectory ( ) : array
return array

setTrackerPluginsNotToLoad() public method

Do not load the specified plugins (used during testing, to disable Provider plugin)
public setTrackerPluginsNotToLoad ( array $plugins )
$plugins array

uninstallPlugin() public method

Uninstalls a Plugin (deletes plugin files from the disk) Only deactivated plugins can be uninstalled
public uninstallPlugin ( $pluginName ) : boolean
$pluginName
return boolean

unloadPlugin() public method

Unload plugin
public unloadPlugin ( Plugin | string $plugin )
$plugin Piwik\Plugin | string

unloadPlugins() public method

Unload all loaded plugins
public unloadPlugins ( )

Property Details

$doLoadAlwaysActivatedPlugins protected property

protected $doLoadAlwaysActivatedPlugins

$doLoadPlugins protected property

protected $doLoadPlugins

$loadedPlugins protected property

protected Plugin[],Piwik $loadedPlugins
return Piwik\Plugin[]

$pluginToAlwaysActivate protected property

These are always activated and cannot be deactivated
protected $pluginToAlwaysActivate

$pluginsToLoad protected property

protected $pluginsToLoad