public function editregistryAction()
 {
     if (!SecurityUtil::checkPermission('Categories::', "::", ACCESS_ADMIN)) {
         throw new \Zikula\Framework\Exception\ForbiddenException();
     }
     $root_id = $this->request->get('dr', 1);
     $id = $this->request->get('id', 0);
     $obj = new \Zikula\Core\Doctrine\Entity\CategoryRegistry();
     $category_registry = $this->request->query->get('category_registry', null);
     if ($category_registry) {
         $obj->merge($category_registry);
         $obj = $obj->toArray();
     }
     $registries = $this->entityManager->getRepository('Zikula\\Core\\Doctrine\\Entity\\CategoryRegistry')->findBy(array(), array('modname' => 'ASC', 'property' => 'ASC'));
     $this->view->assign('objectArray', $registries)->assign('newobj', $obj)->assign('root_id', $root_id)->assign('id', $id);
     return $this->response($this->view->fetch('Admin/registry_edit.tpl'));
 }
 /**
  * Register module categories.
  *
  * @param array $catregs The array of category map data objects.
  *
  * @return boolean
  */
 public static function registerModuleCategories($catregs)
 {
     if (!$catregs) {
         return false;
     }
     $em = \ServiceUtil::get('doctrine')->getManager();
     foreach ($catregs as $catreg) {
         if ($catreg['id']) {
             $entity = $em->getRepository('Zikula\\Core\\Doctrine\\Entity\\CategoryRegistry')->find($catreg['id']);
         } else {
             $entity = new \Zikula\Core\Doctrine\Entity\CategoryRegistry();
         }
         $entity->merge($catreg);
         $em->persist($entity);
     }
     $em->flush();
     return true;
 }
 public function editregistryAction()
 {
     $this->checkCsrfToken();
     if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADMIN)) {
         throw new \Zikula\Framework\Exception\ForbiddenException();
     }
     // delete registry
     if ($this->request->request->get('mode', null) == 'delete') {
         $id = $this->request->get('id', 0);
         $obj = $this->entityManager->find('Zikula\\Core\\Doctrine\\Entity\\CategoryRegistry', $id);
         $this->entityManager->remove($obj);
         $this->entityManager->flush();
         LogUtil::registerStatus(__('Done! Deleted the category registry entry.'));
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry'));
     }
     $args = array();
     if (!$this->request->request->get('category_submit', null)) {
         // got here through selector auto-submit
         $data = $this->request->request->get('category_registry', null);
         $args['category_registry'] = $data;
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry', $args));
     }
     // get data from post
     $data = $this->request->request->get('category_registry', null);
     // do some validation
     if (empty($data['modname'])) {
         $args['category_registry'] = $data;
         LogUtil::registerError(__('Error! You did not select a module.'));
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry', $args));
     }
     if (empty($data['entityname'])) {
         $args['category_registry'] = $data;
         LogUtil::registerError(__('Error! You did not select an entity.'));
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry', $args));
     }
     if (empty($data['property'])) {
         $args['category_registry'] = $data;
         LogUtil::registerError(__('Error! You did not enter a property name.'));
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry', $args));
     }
     if ((int) $data['category_id'] == 0) {
         $args['category_registry'] = $data;
         LogUtil::registerError(__('Error! You did not select a category.'));
         return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry', $args));
     }
     if (isset($data['id']) && (int) $data['id'] > 0) {
         // update existing registry
         $obj = $this->entityManager->find('Zikula\\Core\\Doctrine\\Entity\\CategoryRegistry', $data['id']);
     } else {
         // save the new registry
         $obj = new \Zikula\Core\Doctrine\Entity\CategoryRegistry();
     }
     $obj->merge($data);
     $this->entityManager->persist($obj);
     $this->entityManager->flush();
     LogUtil::registerStatus(__('Done! Saved the category registry entry.'));
     return $this->redirect(ModUtil::url('Categories', 'admin', 'editregistry'));
 }