public function addCategory(Category $category) { $categoryId = $category->getId(); if ($this->hasCategory($categoryId)) { throw new \Exception(sprintf('Category %s already exists', $categoryId)); } $this->categories[$categoryId] = $category; }
public function buildPageMetadata(Category $category, Subcategory $subcategory, $widgetConfigs) { $ca = array('uniqueId' => $this->buildPageId($category->getId(), $subcategory->getId()), 'category' => $this->buildCategoryMetadata($category), 'subcategory' => $this->buildSubcategoryMetadata($subcategory), 'widgets' => array()); foreach ($widgetConfigs as $config) { $ca['widgets'][] = $this->buildWidgetMetadata($config); } return $ca; }