/** * create an admin category * * @param mixed[] $args { * @type string $name name of the category * @type string $description description of the category * } * * @return int|bool admin category ID on success, false on failure * * @throws \InvalidArgumentException Thrown if invalid parameters are received in $args */ public function create($args) { // Argument check if (!isset($args['name']) || !strlen($args['name']) || !isset($args['description'])) { throw new \InvalidArgumentException(__('Invalid arguments array received')); } $args['sortorder'] = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'countitems'); $item = new AdminCategoryEntity(); $item->merge($args); $this->entityManager->persist($item); $this->entityManager->flush(); // Return the id of the newly created item to the calling process return $item['cid']; }
/** * create the default data for the modules module * * This function is only ever called once during the lifetime of a particular * module instance * * @return bool false */ public function defaultdata() { $records = array(array('name' => $this->__('System'), 'description' => $this->__('Core modules at the heart of operation of the site.')), array('name' => $this->__('Layout'), 'description' => $this->__("Layout modules for controlling the site's look and feel.")), array('name' => $this->__('Users'), 'description' => $this->__('Modules for controlling user membership, access rights and profiles.')), array('name' => $this->__('Content'), 'description' => $this->__('Modules for providing content to your users.')), array('name' => $this->__('Uncategorised'), 'description' => $this->__('Newly-installed or uncategorized modules.')), array('name' => $this->__('Security'), 'description' => $this->__('Modules for managing the site\'s security.'))); foreach ($records as $record) { $item = new AdminCategoryEntity(); $item->merge($record); $this->entityManager->persist($item); } $this->entityManager->flush(); }