function categorize($package, $category) { $categories = new Categories($this->channel); if (!$categories->exists($category)) { echo 'That category doesn\'t exist yet. Use add-category first' . PHP_EOL; } $categories->linkPackageToCategory($package, $category); $rcat = new REST\Category($this->restpath, $this->channel, 'rest/', $categories); $rcat->savePackages($category); $rcat->savePackagesInfo($category); }
function handleAddCategory() { if ($_SERVER['argc'] < 3) { $this->printCategoryUsage(); return false; } $args = array(); $args['category'] = $_SERVER['argv'][2]; $args['description'] = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : $_SERVER['argv'][2]; $this->getSCS(); $categories = new Categories($this->channel); $categories->create($args['category'], $args['description']); $category = new REST\Category($this->dir . '/rest', $this->channel, 'rest/', $categories); $category->saveAllCategories(); $category->savePackagesInfo($args['category']); echo "Added category ", $args['category'], "\n"; }