PHP Class Piwik\Widget\WidgetsList

Widgets are added through the {@hook WidgetsList.addWidgets} and filtered through the {@hook Widgets.filterWidgets} event. Observers for this event should call the {@link addWidget()} method to add widgets or use any of the other methods to remove widgets.
Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
addToContainerWidget ( string $containerId, WidgetConfig $widget ) Add a widget to a widget container. It doesn't matter whether the container was added to this list already or whether the container is added later. As long as a container having the same containerId is added at some point the widget will be added to that container. If no container having this id is added the widget will not be recognized.
addWidgetConfig ( WidgetConfig $widget ) Adds a new widget to the widget config. Please make sure the widget is enabled before adding a widget as no such checks will be performed.
addWidgetConfigs ( WidgetConfig[] $widgets ) Add multiple widget configs at once. See {@link addWidgetConfig()}.
get ( ) : static Get all widgets defined in the Piwik platform.
getWidgetConfigs ( ) : WidgetConfig[] Get all added widget configs.
getWidgetUniqueId ( $controllerName, $controllerAction, array $customParameters = [] ) : string CAUTION! If you ever change this method, existing updates will fail as they currently use that method! If you change the output the uniqueId for existing widgets would not be found anymore
isDefined ( string $module, string $action ) : boolean Returns true if a widget exists in the widget list, false if otherwise.
remove ( string $widgetCategoryId, string | false $widgetName = false ) Removes one or more widgets from the widget list.

Private Methods

Method Description
addContainer ( WidgetContainerConfig $containerWidget )
checkIsValidWidget ( WidgetConfig $widget )

Method Details

addToContainerWidget() public method

Add a widget to a widget container. It doesn't matter whether the container was added to this list already or whether the container is added later. As long as a container having the same containerId is added at some point the widget will be added to that container. If no container having this id is added the widget will not be recognized.
public addToContainerWidget ( string $containerId, WidgetConfig $widget )
$containerId string eg 'Products' or 'Contents'. See {@link WidgetContainerConfig::setId}
$widget WidgetConfig

addWidgetConfig() public method

Adds a new widget to the widget config. Please make sure the widget is enabled before adding a widget as no such checks will be performed.
public addWidgetConfig ( WidgetConfig $widget )
$widget WidgetConfig

addWidgetConfigs() public method

Add multiple widget configs at once. See {@link addWidgetConfig()}.
public addWidgetConfigs ( WidgetConfig[] $widgets )
$widgets WidgetConfig[]

get() public static method

Get all widgets defined in the Piwik platform.
public static get ( ) : static
return static

getWidgetConfigs() public method

Get all added widget configs.
public getWidgetConfigs ( ) : WidgetConfig[]
return WidgetConfig[]

getWidgetUniqueId() public static method

Returns the unique id of an widget with the given parameters
public static getWidgetUniqueId ( $controllerName, $controllerAction, array $customParameters = [] ) : string
$controllerName
$controllerAction
$customParameters array
return string

isDefined() public method

Returns true if a widget exists in the widget list, false if otherwise.
public isDefined ( string $module, string $action ) : boolean
$module string The controller name of the widget.
$action string The controller action of the widget.
return boolean

remove() public method

Removes one or more widgets from the widget list.
public remove ( string $widgetCategoryId, string | false $widgetName = false )
$widgetCategoryId string The widget category id. Can be a translation token eg 'General_Visits' see {@link WidgetConfig::setCategoryId()}.
$widgetName string | false The name of the widget to remove eg 'VisitTime_ByServerTimeWidgetName'. If not supplied, all widgets within that category will be removed.