Ejemplo n.º 1
0
 public function save(Classification $classification)
 {
     $data = array('name' => $classification->getName(), 'user_type' => $classification->getUserType(), 'description' => $classification->getDescription());
     $id = (int) $classification->getId();
     $params = array();
     $params['table'] = $this->tableGateway->getTableName();
     $params['operation'] = 1;
     $params['data'] = json_encode($data);
     if ($id == 0) {
         $this->tableGateway->insert($data);
         $id = $this->tableGateway->getLastInsertValue();
         if ($id) {
             $params['id'] = $id;
             $this->featureSet->getEventManager()->trigger("log.save", $this, $params);
             return $id;
         } else {
             return false;
         }
     } else {
         if ($this->get($id)) {
             $params['id'] = $id;
             $params['operation'] = 2;
             $this->featureSet->getEventManager()->trigger("log.save", $this, $params);
             $this->tableGateway->update($data, array('id' => $id));
             return $id;
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 2
0
 public function addAction()
 {
     $form = $this->getServiceLocator()->get("Admin\\Form\\ClassificationForm");
     $request = $this->getRequest();
     if ($request->isPost()) {
         $classification = new Classification();
         $form->setInputFilter($classification->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             $classification->exchangeArray($data);
             $this->getClassificationTable()->save($classification);
             return $this->redirect()->toRoute('admin/classification');
         }
     }
     return array('form' => $form, 'config' => $this->config);
 }