Piwik\Report\

ReportWidgetFactory

Report widget factory.

.. When creating a widget from a report these values will be automatically specified so that ideally $factory->createWidget() is all one has to do in order to create a new widget.

Methods

The class defines the following methods:

  • __construct() — Generates a new report widget factory.
  • createWidget() — Creates a widget based on the specified report in construct().
  • createContainerWidget() — Creates a new container widget based on the specified report in construct().
  • createCustomWidget() — Creates a custom widget that doesn't use a viewDataTable to render the report but instead a custom controller action.

__construct()

Generates a new report widget factory.

Signature

  • It accepts the following parameter(s):
    • $report (Report) — A report instance, widgets will be created based on the data provided by this report.

createWidget()

Creates a widget based on the specified report in construct().

It will automatically use the report's name, categoryId, subcategoryId (if specified), defaultViewDataTable, module, action, order and parameters in order to create the widget.

Signature

createContainerWidget()

Creates a new container widget based on the specified report in construct().

It will automatically use the report's categoryId, subcategoryId (if specified) and order in order to create the container.

Signature

  • It accepts the following parameter(s):
    • $containerId (string) — eg 'Products' or 'Contents' see {Piwik\Widget\WidgetContainerConfig::setId()}. Other reports or widgets will be able to add more widgets to this container. This is useful when you want to show for example multiple related widgets together.
  • It returns a WidgetContainerConfig value.

createCustomWidget()

Creates a custom widget that doesn't use a viewDataTable to render the report but instead a custom controller action. Make sure the specified $action exists in the plugin's controller. Otherwise behaves as createWidget().

Signature

  • It accepts the following parameter(s):
    • $action (string) — eg 'conversionReports' (requires a method public function conversionReports() in the plugin's controller).
  • It returns a ReportWidgetConfig value.