PHP Класс Piwik\ViewDataTable\Factory

### Examples **Creating a ViewDataTable for a report** method in MyPlugin\Controller public function myReport() { $view = Factory::build('table', 'MyPlugin.myReport'); $view->config->show_limit_control = true; $view->config->translations['myFancyMetric'] = "My Fancy Metric"; return $view->render(); } **Displaying a report in another way** method in MyPlugin\Controller use the same data that's used in myReport() above, but transform it in some way before displaying. public function myReportShownDifferently() { $view = Factory::build('table', 'MyPlugin.myReport', 'MyPlugin.myReportShownDifferently'); $view->config->filters[] = array('MyMagicFilter', array('an arg', 'another arg')); return $view->render(); } **Force a report to be shown as a bar graph** method in MyPlugin\Controller force the myReport report to show as a bar graph if there is no viewDataTable query param, even though it is configured to show as a table. public function myReportShownAsABarGraph() { $view = Factory::build('graphVerticalBar', 'MyPlugin.myReport', 'MyPlugin.myReportShownAsABarGraph', $forceDefault = true); return $view->render(); }
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
build ( string | null $defaultType = null, boolean | false | string $apiAction = false, boolean | false | string $controllerAction = false, boolean $forceDefault = false, boolean $loadViewDataTableParametersForUser = null ) : ViewDataTable Creates a {@link Piwik\Plugin\ViewDataTable} instance by ID. If the **viewDataTable** query parameter is set, this parameter's value is used as the ID.

Приватные методы

Метод Описание
createViewDataTableInstance ( string $klass, string $controllerAction, string $apiAction, array $params ) : ViewDataTable
getDefaultViewTypeForReport ( Report $report, string $apiAction ) : boolean | string Returns the default viewDataTable ID to use when determining which visualization to use.
getReport ( $apiAction ) : null | Report Return the report object for the given apiAction
isDefaultViewTypeForReportFixed ( Report $report ) : boolean Returns if the default viewDataTable ID to use is fixed.

Описание методов

build() публичный статический Метод

See {@link Piwik\Plugin\ViewDataTable} to read about the visualizations that are packaged with Piwik.
public static build ( string | null $defaultType = null, boolean | false | string $apiAction = false, boolean | false | string $controllerAction = false, boolean $forceDefault = false, boolean $loadViewDataTableParametersForUser = null ) : ViewDataTable
$defaultType string | null A ViewDataTable ID representing the default ViewDataTable type to use. If the **viewDataTable** query parameter is not found, this value is used as the ID of the ViewDataTable to create. If a visualization type is configured for the report being displayed, it is used instead of the default type. (See {@hook ViewDataTable.getDefaultType}). If nothing is configured for the report and `null` is supplied for this argument, **table** is used.
$apiAction boolean | false | string The API method for the report that will be displayed, eg, `'DevicesDetection.getBrowsers'`.
$controllerAction boolean | false | string The controller name and action dedicated to displaying the report. This action is used when reloading reports or changing the report visualization. Defaulted to `$apiAction` if `false` is supplied.
$forceDefault boolean If true, then the visualization type that was configured for the report will be ignored and `$defaultType` will be used as the default.
$loadViewDataTableParametersForUser boolean Whether the per-user parameters for this user, this ViewDataTable and this Api action should be loaded from the user preferences and override the default params values.
Результат Piwik\Plugin\ViewDataTable