/** * create the category tree * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If Root category not found. * @throws \Exception * * @return boolean */ private function createCategoryTree() { // create category \CategoryUtil::createCategory('/__SYSTEM__/Modules', $this->bundle->getName(), null, $this->__('Gallery'), $this->__('Gallery categories')); // create subcategory \CategoryUtil::createCategory('/__SYSTEM__/Modules/KaikmediaGalleryModule', 'Category1', null, $this->__('Category 1'), $this->__('Initial sub-category created on install'), array('color' => '#99ccff')); \CategoryUtil::createCategory('/__SYSTEM__/Modules/KaikmediaGalleryModule', 'Category2', null, $this->__('Category 2'), $this->__('Initial sub-category created on install'), array('color' => '#cceecc')); // get the category path to insert Pages categories $rootcat = \CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/KaikmediaGalleryModule'); if ($rootcat) { // create an entry in the categories registry to the Main property if (!\CategoryRegistryUtil::insertEntry($this->bundle->getName(), 'AlbumEntity', 'Main', $rootcat['id'])) { throw new \Exception('Cannot insert Category Registry entry.'); } } else { throw new NotFoundHttpException('Root category not found.'); } return true; }
/** * import the categories provided */ private function importCategories() { $rootCatId = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', ModUtil::getVar('Content', 'categoryPropPrimary')); $rootCatObj = CategoryUtil::getCategoryById($rootCatId); $this->categoryPathMap[$this->rootCategoryLocalId] = $rootCatObj['path']; $this->categoryMap[$this->rootCategoryLocalId] = (int) $rootCatId; $oldCategories = $this->getCategories(); foreach ($oldCategories as $oldCategory) { if (isset($this->categoryPathMap[$oldCategory['pid']])) { $id = CategoryUtil::createCategory($this->categoryPathMap[$oldCategory['pid']], $oldCategory['title'], null, $oldCategory['title'], $oldCategory['title']); $catObj = CategoryUtil::getCategoryById($id); $this->categoryPathMap[$oldCategory['id']] = $catObj['path']; $this->categoryMap[$oldCategory['id']] = (int) $id; } } }
/** * Provide default categories. * * @return void */ protected function defaultcategories() { if (!($cat = CategoryUtil::createCategory('/__SYSTEM__/Modules', 'ExampleDoctrine', null, $this->__('ExampleDoctrine'), $this->__('ExampleDoctrine categories')))) { return false; } $rootcat = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/ExampleDoctrine'); CategoryRegistryUtil::insertEntry('ExampleDoctrine', 'User', 'Main', $rootcat['id']); CategoryUtil::createCategory('/__SYSTEM__/Modules/ExampleDoctrine', 'category1', null, $this->__('Category 1'), $this->__('Category 1')); }