ReportWidgetConfig
Piwik\Report\
ReportWidgetConfig
Defines a widget config that is used to render a report.
Methods
The class defines the following methods:
setCategoryId()ash; Set the id of the category the widget belongs to. Inherited fromWidgetConfiggetCategoryId()ash; Get the id of the category the widget belongs to. Inherited fromWidgetConfigsetSubcategoryId()ash; Set the id of the subcategory the widget belongs to. Inherited fromWidgetConfiggetSubcategoryId()ash; Get the currently set category ID. Inherited fromWidgetConfigsetModule()ash; Set the module (aka plugin name) of the widget. Inherited fromWidgetConfiggetModule()Inherited fromWidgetConfigsetAction()ash; Set the action of the widget that shall be used in the URL to render the widget. Inherited fromWidgetConfiggetAction()ash; Get the currently set action. Inherited fromWidgetConfigsetParameters()ash; Sets (overwrites) the parameters of the widget. Inherited fromWidgetConfigaddParameters()ash; Add new parameters and only overwrite parameters that have the same name. Inherited fromWidgetConfiggetParameters()setName()ash; Set the name of the widget. Inherited fromWidgetConfiggetName()ash; Get the name of the widget. Inherited fromWidgetConfigsetOrder()ash; Set the order of the widget. Inherited fromWidgetConfiggetOrder()ash; Returns the order of the widget. Inherited fromWidgetConfigisEnabled()ash; Defines whether a widget is enabled or not. Inherited fromWidgetConfigsetIsEnabled()ash; Enable / disable the widget. Inherited fromWidgetConfigenable()ash; Enables the widget. Inherited fromWidgetConfigdisable()ash; Disables the widget. Inherited fromWidgetConfigcheckIsEnabled()ash; This method checks whether the widget is available, see isEnabled(). Inherited fromWidgetConfiggetUniqueId()ash; Returns the unique id of an widget based on module, action and the set parameters. Inherited fromWidgetConfigsetIsNotWidgetizable()ash; Sets the widget as not widgetizable isWidgetizeable(). Inherited fromWidgetConfigsetIsWidgetizable()ash; Sets the widget as widgetizable isWidgetizeable(). Inherited fromWidgetConfigisWidgetizeable()ash; Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. Inherited fromWidgetConfigsetMiddlewareParameters()ash; If middleware parameters are specified, the corresponding action will be executed before showing the actual widget in the UI. Inherited fromWidgetConfiggetMiddlewareParameters()ash; Get defined middleware parameters (if any). Inherited fromWidgetConfigsetIsWide()ash; Marks this widget as a "wide" widget that requires the full width. Inherited fromWidgetConfigisWide()ash; Detect whether the widget should be shown wide or not. Inherited fromWidgetConfigsetDefaultViewDataTable()— Sets a default viewDataTable that should be used to render the report.forceViewDataTable()— Forces the usage of the given viewDataTable in order to render the report.isViewDataTableForced()— Detect whether a defined viewDataTable should be forced in order to render a report.getViewDataTable()— Get the specified viewDataTable.
setCategoryId()
Set the id of the category the widget belongs to.
Signature
- It accepts the following parameter(s):
$categoryId(string) — Usually a translation key, eg 'General_Visits', 'Goals_Goals', ...
- It returns a
WidgetConfigvalue.
getCategoryId()
Get the id of the category the widget belongs to.
Signature
- It returns a
stringvalue.
setSubcategoryId()
Set the id of the subcategory the widget belongs to. If a subcategory is specified, the widget will be shown in the Matomo (formerly Piwik) reporting UI. The subcategoryId will be used as a translation key for the submenu item.
Signature
- It accepts the following parameter(s):
$subcategoryId(string) — Usually a translation key, eg 'General_Overview', 'Actions_Pages', ...
- It returns a
WidgetConfigvalue.
getSubcategoryId()
Get the currently set category ID.
Signature
- It returns a
stringvalue.
setModule()
Set the module (aka plugin name) of the widget. The correct module is usually detected automatically and not needed to be configured manually.
Signature
- It accepts the following parameter(s):
$module(string) — eg 'CoreHome'
- It returns a
WidgetConfigvalue.
getModule()
Signature
- It does not return anything or a mixed result.
setAction()
Set the action of the widget that shall be used in the URL to render the widget.
The correct action is usually detected automatically and not needed to be configured manually.
Signature
- It accepts the following parameter(s):
$action(string) — eg 'renderMyWidget'
- It returns a
WidgetConfigvalue.
getAction()
Get the currently set action.
Signature
- It returns a
stringvalue.
setParameters()
Sets (overwrites) the parameters of the widget. These parameters will be added to the URL when rendering the widget. You can access these parameters via `Piwik\Common::getRequestVar(.
..)`.
Signature
- It accepts the following parameter(s):
$parameters(array) — eg. ('urlparam' => 'urlvalue')
- It returns a
WidgetConfigvalue.
addParameters()
Add new parameters and only overwrite parameters that have the same name. See setParameters()
Signature
- It accepts the following parameter(s):
$parameters(array) — eg. ('urlparam' => 'urlvalue')
- It returns a
WidgetConfigvalue.
getParameters()
Signature
- Returns:
array— Eg ('urlparam' => 'urlvalue').
setName()
Set the name of the widget.
Signature
- It accepts the following parameter(s):
$name(string) — Usually a translation key, eg 'VisitTime_ByServerTimeWidgetName'
- It returns a
WidgetConfigvalue.
getName()
Get the name of the widget.
Signature
- It returns a
stringvalue.
setOrder()
Set the order of the widget.
Signature
- It accepts the following parameter(s):
$order(int) — eg. 5
- It returns a
WidgetConfigvalue.
getOrder()
Returns the order of the widget.
Signature
- It returns a
intvalue.
isEnabled()
Defines whether a widget is enabled or not. For instance some widgets might not be available to every user or
might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then
return true or false. If your report is only available to users having super user access you can do the
following: return Piwik::hasUserSuperUserAccess();
Signature
- It returns a
boolvalue.
setIsEnabled()
Enable / disable the widget. See isEnabled()
Signature
It accepts the following parameter(s):
$isEnabled(bool) —
It returns a
WidgetConfigvalue.
enable()
Enables the widget. See isEnabled()
Signature
- It does not return anything or a mixed result.
disable()
Disables the widget. See isEnabled()
Signature
- It does not return anything or a mixed result.
checkIsEnabled()
This method checks whether the widget is available, see isEnabled(). If not, it triggers an exception containing a message that will be displayed to the user. You can overwrite this message in case you want to customize the error message. Eg.
if (!$this->isEnabled()) {
throw new Exception('Setting XYZ is not enabled or the user has not enough permission');
}
Signature
- It does not return anything or a mixed result.
- It throws one of the following exceptions:
getUniqueId()
Returns the unique id of an widget based on module, action and the set parameters.
Signature
- It returns a
stringvalue.
setIsNotWidgetizable()
Sets the widget as not widgetizable isWidgetizeable().
Signature
- It returns a
WidgetConfigvalue.
setIsWidgetizable()
Sets the widget as widgetizable isWidgetizeable().
Signature
- It returns a
WidgetConfigvalue.
isWidgetizeable()
Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. This is usually not needed but useful when you eg want to display a widget within the Matomo UI but not want to have it widgetizable.
Signature
- It returns a
boolvalue.
setMiddlewareParameters()
If middleware parameters are specified, the corresponding action will be executed before showing the
actual widget in the UI. Only if this action (can be a controller method or API method) returns JSON true
the widget will be actually shown. It is similar to isEnabled() but the specified action is performed each
time the widget is requested in the UI whereas isEnabled is only checked once on the initial page load when
we load the initial list of widgets. So if your widget's visibility depends on archived data
(aka idSite/period/date) you should specify middle parameters. This has mainly two reasons:
- This way the initial page load time is faster as we won't have to request archived data on the initial page load for widgets that are potentially never shown.
- We execute that action every time before showing it. As the initial list of widgets is loaded on page load
it is possible that some archives have no data yet, but at a later time there might be actually archived data.
As we never reload the initial list of widgets we would still not show the widget even there we should. Example:
On page load there are no conversions, a few minutes later there might be conversions. As the middleware is
executed before showing it, we detect correctly that there are now conversions whereas
isEnabledis only checked once on the initial Matomo page load.
Signature
- It accepts the following parameter(s):
$parameters(array) — URL parameters eg array('module' => 'Goals', 'action' => 'Conversions')
- It returns a
WidgetConfigvalue.
getMiddlewareParameters()
Get defined middleware parameters (if any).
Signature
- It returns a
arrayvalue.
setIsWide()
Marks this widget as a "wide" widget that requires the full width.
Signature
- It returns a
$thisvalue.
isWide()
Detect whether the widget should be shown wide or not.
Signature
- It returns a
boolvalue.
setDefaultViewDataTable()
Sets a default viewDataTable that should be used to render the report. This is not necessarily the view that will be actually used to render the report. Eg if a user switched manually to another viewDataTable Matomo will re-use the viewDataTable that was used the last time. If you want to force the usage of a viewDataTable use forceViewDataTable().
Signature
- It accepts the following parameter(s):
$viewDataTableId(string) — eg 'table' or 'graph'
- It returns a
ReportWidgetConfigvalue.
forceViewDataTable()
Forces the usage of the given viewDataTable in order to render the report.
Signature
- It accepts the following parameter(s):
$viewDataTableId(string) — eg 'table' or 'graph'
- It returns a
$thisvalue.
isViewDataTableForced()
Detect whether a defined viewDataTable should be forced in order to render a report.
Signature
- It returns a
boolvalue.
getViewDataTable()
Get the specified viewDataTable.
Signature
- It returns a
stringvalue.