Piwik\Report\ReportWidgetFactory::createContainerWidget PHP Метод

createContainerWidget() публичный Метод

It will automatically use the report's categoryId, subcategoryId (if specified) and order in order to create the container.
public createContainerWidget ( string $containerId ) : WidgetContainerConfig
$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.
Результат Piwik\Widget\WidgetContainerConfig
    public function createContainerWidget($containerId)
    {
        $widget = new WidgetContainerConfig();
        $widget->setCategoryId($this->report->getCategoryId());
        $widget->setId($containerId);
        if ($this->report->getSubcategoryId()) {
            $widget->setSubcategoryId($this->report->getSubcategoryId());
        }
        $orderThatListsReportsAtTheEndOfEachCategory = 100 + $this->report->getOrder();
        $widget->setOrder($orderThatListsReportsAtTheEndOfEachCategory);
        return $widget;
    }

Usage Example

Пример #1
0
 public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
 {
     $widgetsList->addWidgetConfig($factory->createContainerWidget('Continent'));
     $widgetsList->addToContainerWidget('Continent', $factory->createWidget());
     $widget = $factory->createWidget()->setAction('getDistinctCountries')->setName('');
     $widgetsList->addToContainerWidget('Continent', $widget);
 }