Ejemplo n.º 1
0
 /**
  * Save a hook
  *
  */
 public function saveAction()
 {
     $factory = new Utility_Hook_Factory();
     if (@$_REQUEST['id'] > 0) {
         $item = $factory->find($_REQUEST['id'])->current();
     } else {
         $item = $factory->createRow();
     }
     $form = $item->getForm(@$_REQUEST['id']);
     if ($form->isValid($_REQUEST)) {
         $values = $form->getValues();
         list($type, $action, $class) = explode('_', $values['type']);
         $item->type = $type;
         $item->action = $action;
         $item->weight = $values['weight'];
         $item->class = $class;
         $item->save();
         $this->_helper->redirector->gotoRoute(array('module' => 'utility', 'controller' => 'hook', 'action' => 'index'));
     }
     $this->view->form = $form;
     $this->view->form->populate($_REQUEST);
     $factory = new Utility_Hook_Factory();
     $this->view->hooks = $factory->fetchAll(null, "weight");
     $this->render('form');
 }