/**
  * 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;
 }
Example #2
0
 /**
  * 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'));
 }