예제 #1
0
 public function save(PaymentMethod $paymentMethod)
 {
     $data = array('name' => $paymentMethod->getName(), 'bank_info' => $paymentMethod->getBankInfo(), 'description' => $paymentMethod->getDescription());
     $id = (int) $paymentMethod->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;
         }
     }
 }
예제 #2
0
 public function addAction()
 {
     $config = $this->getServiceLocator()->get("config");
     $form = new PaymentMethodForm();
     $form->get('submit')->setValue('guardar');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $paymentMethod = new PaymentMethod();
         $form->setInputFilter($paymentMethod->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $paymentMethod->exchangeArray($form->getData());
             $this->getPaymentMethodTable()->save($paymentMethod);
             return $this->redirect()->toRoute('admin/payment_method');
         }
     }
     return array('form' => $form, 'config' => $this->config);
 }