Piwik\Plugin\Controller::getLastUnitGraphAcrossPlugins PHP Method

getLastUnitGraphAcrossPlugins() protected method

Same as {@link getLastUnitGraph()}, but will set some properties of the ViewDataTable object based on the arguments supplied.
protected getLastUnitGraphAcrossPlugins ( string $currentModuleName, string $currentControllerAction, array $columnsToDisplay = false, array $selectableColumns = [], boolean | string $reportDocumentation = false, string $apiMethod = 'API.get' ) : ViewDataTable
$currentModuleName string The name of the current plugin.
$currentControllerAction string The name of the action that renders the desired report.
$columnsToDisplay array The value to use for the ViewDataTable's columns_to_display config property.
$selectableColumns array The value to use for the ViewDataTable's selectable_columns config property.
$reportDocumentation boolean | string The value to use for the ViewDataTable's documentation config property.
$apiMethod string The API method that the ViewDataTable will use to get graph data.
return ViewDataTable
    protected function getLastUnitGraphAcrossPlugins($currentModuleName, $currentControllerAction, $columnsToDisplay = false, $selectableColumns = array(), $reportDocumentation = false, $apiMethod = 'API.get')
    {
        // load translations from meta data
        $idSite = Common::getRequestVar('idSite');
        $period = Common::getRequestVar('period');
        $date = Common::getRequestVar('date');
        $meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
        $columns = array_merge($columnsToDisplay ? $columnsToDisplay : array(), $selectableColumns);
        $translations = array_combine($columns, $columns);
        foreach ($meta as $reportMeta) {
            if ($reportMeta['action'] == 'get' && !isset($reportMeta['parameters'])) {
                foreach ($columns as $column) {
                    if (isset($reportMeta['metrics'][$column])) {
                        $translations[$column] = $reportMeta['metrics'][$column];
                    }
                }
            }
        }
        // initialize the graph and load the data
        $view = $this->getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod);
        if ($columnsToDisplay !== false) {
            $view->config->columns_to_display = $columnsToDisplay;
        }
        if (property_exists($view->config, 'selectable_columns')) {
            $view->config->selectable_columns = array_merge($view->config->selectable_columns ?: array(), $selectableColumns);
        }
        $view->config->translations += $translations;
        if ($reportDocumentation) {
            $view->config->documentation = $reportDocumentation;
        }
        return $view;
    }