PHP 클래스 Piwik\Plugin\Report

You can create a new report using the console command ./console generate:report. The generated report will guide you through the creation of a report.
부터: 2.5.0
파일 보기 프로젝트 열기: piwik/piwik 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$action string The name of the action. The action is detected automatically depending on the file name. A corresponding action should exist in the API as well.
$actionToLoadSubTables string The name of the API action to load a subtable if supported. The action has to be of the same module. For instance a report "getKeywords" might support a subtable "getSearchEngines" which shows how often a keyword was searched via a specific search engine.
$categoryId string The translation key of the category the report belongs to.
$constantRowsCount boolean Set it to boolean true if your report always returns a constant count of rows, for instance always 24 rows for 1-24 hours.
$defaultSortColumn string | integer Default sort column. Either a column name or a column id.
$defaultSortOrderDesc boolean Default sort desc. If true will sort by default desc, if false will sort by default asc
$dimension Piwik\Columns\Dimension An instance of a dimension if the report has one. You can create a new dimension using the Piwik console CLI tool if needed.
$documentation string A translated documentation which explains the report.
$hasGoalMetrics boolean Set this property to true in case your report supports goal metrics. In this case, the goal metrics will be automatically added to the report metadata and the report will be displayed in the Goals UI.
$isSubtableReport boolean Set it to boolean true if this report is a subtable report and won't be used as a standalone report.
$metrics array ..)`. Defaults to the platform default metrics see {@link Metrics::getDefaultProcessedMetrics()}.
$module string The name of the module which is supposed to be equal to the name of the plugin. The module is detected automatically.
$name string The translated name of the report. The name will be used for instance in the mobile app or if another report defines this report as a related report.
$order integer The order of the report. Depending on the order the report gets a different position in the list of widgets, the menu and the mobile app.
$parameters null | array Some reports may require additional URL parameters that need to be sent when a report is requested. For instance a "goal" report might need a "goalId": array('idgoal' => 5).
$processedMetrics array Eg array('avg_time_on_site', 'nb_actions_per_visit', ...)
$recursiveLabelSeparator string Separator for building recursive labels (or paths)
$subcategoryId string The translation key of the subcategory the report belongs to.

공개 메소드들

메소드 설명
__construct ( ) The constructur initializes the module, action and the default metrics. If you want to overwrite any of those values or if you want to do any work during initializing overwrite the method {@link init()}.
alwaysUseDefaultViewDataTable ( ) : boolean Returns if the default viewDataTable type should always be used. e.g. the type won't be changeable through config or url params.
checkIsEnabled ( ) This method checks whether the report 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.
configureReportMetadata ( &$availableReports, $infos ) If the report is enabled the report metadata for this report will be built and added to the list of available reports. Overwrite this method and leave it empty in case you do not want your report to be added to the report metadata. In this case your report won't be visible for instance in the mobile app and scheduled reports generator. We recommend to change this behavior only if you are familiar with the Piwik core. $infos contains the current requested date, period and site.
configureView ( ViewDataTable $view ) Here you can configure how your report should be displayed and which capabilities your report has. For instance whether your report supports a "search" or not. EG $view->config->show_search = false. You can also change the default request config. For instance you can change how many rows are displayed by default: $view->requestConfig->filter_limit = 10;. See {@link ViewDataTable} for more information.
configureWidgets ( WidgetsList $widgetsList, ReportWidgetFactory $factory ) lets you add any amount of widgets for this report. If a report defines a {@link $categoryId} and a {@link $subcategoryId} a widget will be generated automatically.
fetch ( array $paramOverride = [] ) : DataTable Fetches the report represented by this instance.
fetchSubtable ( integer $idSubtable, array $paramOverride = [] ) : DataTable Fetches a subtable for the report represented by this instance.
getAction ( ) : string Get the name of the action.
getActionToLoadSubTables ( ) : string Get the action to load sub tables if one is defined.
getAllMetrics ( ) : array Returns the array of all metrics displayed by this report.
getCategoryId ( ) : string Get the translated name of the category the report belongs to.
getDefaultSortColumn ( )
getDefaultSortOrder ( )
getDefaultTypeViewDataTable ( ) : string Returns the id of the default visualization for this report. Eg 'table' or 'pie'. Defaults to the HTML table.
getDimension ( ) : Dimension
getDocumentation ( ) : string Get report documentation.
getForDimension ( Dimension $dimension ) : Report | null Finds a top level report that provides stats for a specific Dimension.
getMetrics ( ) : array Returns an array of supported metrics and their corresponding translations. Eg array('nb_visits' => 'Visits').
getMetricsForTable ( DataTable $dataTable, Report $report = null, string $baseType = 'Piwik\Plugin\Metric' ) : Metric[] Returns the Metrics that are displayed by a DataTable of a certain Report type.
getMetricsRequiredForReport ( string[] | null $allMetrics = null, string[] | null $restrictToColumns = null ) : string[] Returns the list of metrics required at minimum for a report factoring in the columns requested by the report requester.
getModule ( ) : string Get the name of the module.
getName ( ) : string Get the name of the report
getOrder ( ) : integer Returns the order of the report
getParameters ( )
getProcessedMetrics ( ) : array | mixed Returns an array of supported processed metrics and their corresponding translations. Eg array('nb_visits' => 'Visits'). By default the given {@link $processedMetrics} are used and their corresponding translations are looked up automatically. If a metric is not translated, you should add the default metric translation for this metric using the {@hook Metrics.getDefaultMetricTranslations} event. If you want to overwrite any default metric translation you should overwrite this method, call this parent method to get all default translations and overwrite any custom metric translations.
getProcessedMetricsById ( ) : Piwik\Plugin\ProcessedMetric[] Returns an array mapping the ProcessedMetrics served by this report by their string names.
getProcessedMetricsForTable ( DataTable $dataTable, Report $report = null ) : Piwik\Plugin\ProcessedMetric[] Returns the ProcessedMetrics that should be computed and formatted for a DataTable of a certain report. The ProcessedMetrics returned are those specified by the Report metadata as well as the DataTable metadata.
getRecursiveLabelSeparator ( )
getRelatedReports ( ) : Report[] Get the list of related reports if there are any. They will be displayed for instance below a report as a recommended related report.
getSubcategoryId ( ) : string Get the translated name of the subcategory the report belongs to.
getSubtableDimension ( ) : Dimension | null Returns the Dimension instance of this report's subtable report.
hasGoalMetrics ( ) : boolean
isEnabled ( ) : boolean Defines whether a report is enabled or not. For instance some reports 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();
isSubtableReport ( ) : boolean Returns true if the report is for another report's subtable, false if otherwise.
render ( ) : string Renders a report depending on the configured ViewDataTable see {@link configureView()} and {@link getDefaultTypeViewDataTable()}. If you want to customize the render process or just render any custom view you can overwrite this method.

보호된 메소드들

메소드 설명
buildReportMetadata ( ) : array Builts the report metadata for this report. Can be useful in case you want to change the behavior of {@link configureReportMetadata()}.
getMetricsDocumentation ( ) : array Returns an array of metric documentations and their corresponding translations. Eg `array('nb_visits' => 'If a visitor comes to your website for the first time or if he visits a page more than 30 minutes after.
init ( ) Here you can do any instance initialization and overwrite any default values. You should avoid doing time consuming initialization here and if possible delay as long as possible. An instance of this report will be created in most page requests.

비공개 메소드들

메소드 설명
getMetricTranslations ( $metricsToTranslate )
getSubtableApiMethod ( )

메소드 상세

__construct() 최종 공개 메소드

The constructur initializes the module, action and the default metrics. If you want to overwrite any of those values or if you want to do any work during initializing overwrite the method {@link init()}.
final public __construct ( )

alwaysUseDefaultViewDataTable() 공개 메소드

Defaults to false

buildReportMetadata() 보호된 메소드

Builts the report metadata for this report. Can be useful in case you want to change the behavior of {@link configureReportMetadata()}.
protected buildReportMetadata ( ) : array
리턴 array

checkIsEnabled() 공개 메소드

if (!$this->isEnabled()) { throw new Exception('Setting XYZ is not enabled or the user has not enough permission'); }
public checkIsEnabled ( )

configureReportMetadata() 공개 메소드

If the report is enabled the report metadata for this report will be built and added to the list of available reports. Overwrite this method and leave it empty in case you do not want your report to be added to the report metadata. In this case your report won't be visible for instance in the mobile app and scheduled reports generator. We recommend to change this behavior only if you are familiar with the Piwik core. $infos contains the current requested date, period and site.
public configureReportMetadata ( &$availableReports, $infos )
$availableReports
$infos

configureView() 공개 메소드

Here you can configure how your report should be displayed and which capabilities your report has. For instance whether your report supports a "search" or not. EG $view->config->show_search = false. You can also change the default request config. For instance you can change how many rows are displayed by default: $view->requestConfig->filter_limit = 10;. See {@link ViewDataTable} for more information.
public configureView ( ViewDataTable $view )
$view ViewDataTable

configureWidgets() 공개 메소드

Example to add a widget manually by overwriting this method in your report: $widgetsList->addWidgetConfig($factory->createWidget()); If you want to have the name and the order of the widget differently to the name and order of the report you can do the following: $widgetsList->addWidgetConfig($factory->createWidget()->setName('Custom')->setOrder(5)); If you want to add a widget to any container defined by your plugin or by another plugin you can do this: $widgetsList->addToContainerWidget($containerId = 'Products', $factory->createWidget());
public configureWidgets ( WidgetsList $widgetsList, ReportWidgetFactory $factory )
$widgetsList Piwik\Widget\WidgetsList
$factory Piwik\Report\ReportWidgetFactory

fetch() 공개 메소드

Fetches the report represented by this instance.
public fetch ( array $paramOverride = [] ) : DataTable
$paramOverride array Query parameter overrides.
리턴 Piwik\DataTable

fetchSubtable() 공개 메소드

Fetches a subtable for the report represented by this instance.
public fetchSubtable ( integer $idSubtable, array $paramOverride = [] ) : DataTable
$idSubtable integer The subtable ID.
$paramOverride array Query parameter overrides.
리턴 Piwik\DataTable

getAction() 공개 메소드

Get the name of the action.
public getAction ( ) : string
리턴 string

getActionToLoadSubTables() 공개 메소드

Get the action to load sub tables if one is defined.
public getActionToLoadSubTables ( ) : string
리턴 string

getAllMetrics() 공개 메소드

Returns the array of all metrics displayed by this report.
public getAllMetrics ( ) : array
리턴 array

getCategoryId() 공개 메소드

Get the translated name of the category the report belongs to.
public getCategoryId ( ) : string
리턴 string

getDefaultSortColumn() 공개 메소드

getDefaultSortOrder() 공개 메소드

public getDefaultSortOrder ( )

getDefaultTypeViewDataTable() 공개 메소드

Returns the id of the default visualization for this report. Eg 'table' or 'pie'. Defaults to the HTML table.

getDimension() 공개 메소드

public getDimension ( ) : Dimension
리턴 Piwik\Columns\Dimension

getDocumentation() 공개 메소드

Get report documentation.
public getDocumentation ( ) : string
리턴 string

getForDimension() 공개 정적인 메소드

Finds a top level report that provides stats for a specific Dimension.
public static getForDimension ( Dimension $dimension ) : Report | null
$dimension Piwik\Columns\Dimension The dimension whose report we're looking for.
리턴 Report | null The

getMetrics() 공개 메소드

By default the given {@link $metrics} are used and their corresponding translations are looked up automatically. If a metric is not translated, you should add the default metric translation for this metric using the {@hook Metrics.getDefaultMetricTranslations} event. If you want to overwrite any default metric translation you should overwrite this method, call this parent method to get all default translations and overwrite any custom metric translations.
public getMetrics ( ) : array
리턴 array

getMetricsDocumentation() 보호된 메소드

..')`. By default the given {@link $metrics} are used and their corresponding translations are looked up automatically. If there is a metric documentation not found, you should add the default metric documentation translation for this metric using the {@hook Metrics.getDefaultMetricDocumentationTranslations} event. If you want to overwrite any default metric translation you should overwrite this method, call this parent method to get all default translations and overwrite any custom metric translations.
protected getMetricsDocumentation ( ) : array
리턴 array

getMetricsForTable() 공개 정적인 메소드

Includes ProcessedMetrics and Metrics.
public static getMetricsForTable ( DataTable $dataTable, Report $report = null, string $baseType = 'Piwik\Plugin\Metric' ) : Metric[]
$dataTable Piwik\DataTable
$report Report
$baseType string The base type each metric class needs to be of.
리턴 Metric[]

getMetricsRequiredForReport() 공개 메소드

This will return all the metrics requested (or all the metrics in the report if nothing is requested) **plus** the metrics required to calculate the requested processed metrics. This method should be used in **Plugin.get** API methods.
public getMetricsRequiredForReport ( string[] | null $allMetrics = null, string[] | null $restrictToColumns = null ) : string[]
$allMetrics string[] | null The list of all available unprocessed metrics. Defaults to this report's metrics.
$restrictToColumns string[] | null The requested columns.
리턴 string[]

getModule() 공개 메소드

Get the name of the module.
public getModule ( ) : string
리턴 string

getName() 공개 메소드

Get the name of the report
public getName ( ) : string
리턴 string

getOrder() 공개 메소드

Returns the order of the report
public getOrder ( ) : integer
리턴 integer

getParameters() 공개 메소드

public getParameters ( )

getProcessedMetrics() 공개 메소드

Returns an array of supported processed metrics and their corresponding translations. Eg array('nb_visits' => 'Visits'). By default the given {@link $processedMetrics} are used and their corresponding translations are looked up automatically. If a metric is not translated, you should add the default metric translation for this metric using the {@hook Metrics.getDefaultMetricTranslations} event. If you want to overwrite any default metric translation you should overwrite this method, call this parent method to get all default translations and overwrite any custom metric translations.
public getProcessedMetrics ( ) : array | mixed
리턴 array | mixed

getProcessedMetricsById() 공개 메소드

Returns an array mapping the ProcessedMetrics served by this report by their string names.
public getProcessedMetricsById ( ) : Piwik\Plugin\ProcessedMetric[]
리턴 Piwik\Plugin\ProcessedMetric[]

getProcessedMetricsForTable() 공개 정적인 메소드

Returns the ProcessedMetrics that should be computed and formatted for a DataTable of a certain report. The ProcessedMetrics returned are those specified by the Report metadata as well as the DataTable metadata.
public static getProcessedMetricsForTable ( DataTable $dataTable, Report $report = null ) : Piwik\Plugin\ProcessedMetric[]
$dataTable Piwik\DataTable
$report Report
리턴 Piwik\Plugin\ProcessedMetric[]

getRecursiveLabelSeparator() 공개 메소드

getRelatedReports() 공개 메소드

Get the list of related reports if there are any. They will be displayed for instance below a report as a recommended related report.
public getRelatedReports ( ) : Report[]
리턴 Report[]

getSubcategoryId() 공개 메소드

Get the translated name of the subcategory the report belongs to.
public getSubcategoryId ( ) : string
리턴 string

getSubtableDimension() 공개 메소드

Returns the Dimension instance of this report's subtable report.
public getSubtableDimension ( ) : Dimension | null
리턴 Piwik\Columns\Dimension | null The subtable report's dimension or null if there is subtable report or no dimension for the subtable report.

hasGoalMetrics() 공개 메소드

public hasGoalMetrics ( ) : boolean
리턴 boolean

init() 보호된 메소드

Here you can do any instance initialization and overwrite any default values. You should avoid doing time consuming initialization here and if possible delay as long as possible. An instance of this report will be created in most page requests.
protected init ( )

isEnabled() 공개 메소드

Defines whether a report is enabled or not. For instance some reports 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();
public isEnabled ( ) : boolean
리턴 boolean

isSubtableReport() 공개 메소드

Returns true if the report is for another report's subtable, false if otherwise.
public isSubtableReport ( ) : boolean
리턴 boolean

render() 공개 메소드

Renders a report depending on the configured ViewDataTable see {@link configureView()} and {@link getDefaultTypeViewDataTable()}. If you want to customize the render process or just render any custom view you can overwrite this method.
public render ( ) : string
리턴 string

프로퍼티 상세

$action 보호되어 있는 프로퍼티

The name of the action. The action is detected automatically depending on the file name. A corresponding action should exist in the API as well.
protected string $action
리턴 string

$actionToLoadSubTables 보호되어 있는 프로퍼티

The name of the API action to load a subtable if supported. The action has to be of the same module. For instance a report "getKeywords" might support a subtable "getSearchEngines" which shows how often a keyword was searched via a specific search engine.
protected string $actionToLoadSubTables
리턴 string

$categoryId 보호되어 있는 프로퍼티

The translation key of the category the report belongs to.
protected string $categoryId
리턴 string

$constantRowsCount 보호되어 있는 프로퍼티

Set it to boolean true if your report always returns a constant count of rows, for instance always 24 rows for 1-24 hours.
protected bool $constantRowsCount
리턴 boolean

$defaultSortColumn 보호되어 있는 프로퍼티

Default sort column. Either a column name or a column id.
protected string|int $defaultSortColumn
리턴 string | integer

$defaultSortOrderDesc 보호되어 있는 프로퍼티

Default sort desc. If true will sort by default desc, if false will sort by default asc
protected bool $defaultSortOrderDesc
리턴 boolean

$dimension 보호되어 있는 프로퍼티

An instance of a dimension if the report has one. You can create a new dimension using the Piwik console CLI tool if needed.
protected Dimension,Piwik\Columns $dimension
리턴 Piwik\Columns\Dimension

$documentation 보호되어 있는 프로퍼티

A translated documentation which explains the report.
protected string $documentation
리턴 string

$hasGoalMetrics 보호되어 있는 프로퍼티

Set this property to true in case your report supports goal metrics. In this case, the goal metrics will be automatically added to the report metadata and the report will be displayed in the Goals UI.
protected bool $hasGoalMetrics
리턴 boolean

$isSubtableReport 보호되어 있는 프로퍼티

Set it to boolean true if this report is a subtable report and won't be used as a standalone report.
protected bool $isSubtableReport
리턴 boolean

$metrics 보호되어 있는 프로퍼티

..)`. Defaults to the platform default metrics see {@link Metrics::getDefaultProcessedMetrics()}.
protected array $metrics
리턴 array

$module 보호되어 있는 프로퍼티

The name of the module which is supposed to be equal to the name of the plugin. The module is detected automatically.
protected string $module
리턴 string

$name 보호되어 있는 프로퍼티

The translated name of the report. The name will be used for instance in the mobile app or if another report defines this report as a related report.
protected string $name
리턴 string

$order 보호되어 있는 프로퍼티

The order of the report. Depending on the order the report gets a different position in the list of widgets, the menu and the mobile app.
protected int $order
리턴 integer

$parameters 보호되어 있는 프로퍼티

Some reports may require additional URL parameters that need to be sent when a report is requested. For instance a "goal" report might need a "goalId": array('idgoal' => 5).
protected null|array $parameters
리턴 null | array

$processedMetrics 보호되어 있는 프로퍼티

Eg array('avg_time_on_site', 'nb_actions_per_visit', ...)
protected array $processedMetrics
리턴 array

$recursiveLabelSeparator 보호되어 있는 프로퍼티

Separator for building recursive labels (or paths)
protected string $recursiveLabelSeparator
리턴 string

$subcategoryId 보호되어 있는 프로퍼티

The translation key of the subcategory the report belongs to.
protected string $subcategoryId
리턴 string