Piwik\Widget\WidgetConfig::getCategoryId PHP Method

getCategoryId() public method

Get the id of the category the widget belongs to.
public getCategoryId ( ) : string
return string
    public function getCategoryId()
    {
        return $this->categoryId;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param WidgetConfig $widget
  * @param CategoryList|null $categoryList If null, no category information will be added to the widgets in first
  *                                        level (they will be added to nested widgets as potentially needed eg for
  *                                        widgets in ByDimensionView where they are needed to build the left menu)
  * @return array
  */
 public function buildWidgetMetadata(WidgetConfig $widget, $categoryList = null)
 {
     $item = array('name' => Piwik::translate($widget->getName()));
     if (isset($categoryList)) {
         $category = $categoryList->getCategory($widget->getCategoryId());
         $subcategory = $category ? $category->getSubcategory($widget->getSubcategoryId()) : null;
         $item['category'] = $this->buildCategoryMetadata($category);
         $item['subcategory'] = $this->buildSubcategoryMetadata($subcategory);
     }
     $item['module'] = $widget->getModule();
     $item['action'] = $widget->getAction();
     $item['order'] = $widget->getOrder();
     $item['parameters'] = $widget->getParameters();
     $item['uniqueId'] = $widget->getUniqueId();
     $item['isWide'] = $widget->isWide();
     $middleware = $widget->getMiddlewareParameters();
     if (!empty($middleware)) {
         $item['middlewareParameters'] = $middleware;
     }
     if ($widget instanceof ReportWidgetConfig) {
         $item['viewDataTable'] = $widget->getViewDataTable();
         $item['isReport'] = true;
     }
     if ($widget instanceof WidgetContainerConfig) {
         $item['layout'] = $widget->getLayout();
         $item['isContainer'] = true;
         // we do not want to create categories to the inital categoryList. Otherwise we'd maybe display more pages
         // etc.
         $subCategoryList = new CategoryList();
         $this->createMissingCategoriesAndSubcategories($subCategoryList, $widget->getWidgetConfigs());
         $children = array();
         foreach ($widget->getWidgetConfigs() as $widgetConfig) {
             $children[] = $this->buildWidgetMetadata($widgetConfig, $subCategoryList);
         }
         $item['widgets'] = $children;
     }
     return $item;
 }