예제 #1
0
 public function generateResponse()
 {
     $customer = new objects_Customer();
     switch ($this->params['action']) {
         case 'add_customer':
             $response = $customer->save($this->params);
             if ($response['result'] === TRUE) {
                 $this->returnArray['messages']['success'][] = 'Клиент был успешно добавлен.';
                 $this->addReturnParameters();
             } else {
                 $this->returnArray['messages']['danger'][] = $response['error'];
             }
             break;
         case 'edit_customer':
             $response = $customer->save($this->params, $this->params['id']);
             if ($response['result'] === TRUE) {
                 $this->returnArray['messages']['success'][] = 'Клиент был успешно изменен.';
                 $this->addReturnParameters();
             } else {
                 $this->returnArray['messages']['danger'][] = $response['error'];
             }
             break;
         case 'delete_customer':
             $response = $customer->delete($this->params['id']);
             if ($response['result'] === TRUE) {
                 $this->returnArray['messages']['success'][] = 'Клиент был успешно удален.';
                 $this->addReturnParameters();
             } else {
                 $this->returnArray['messages']['danger'][] = $response['error'];
             }
             break;
         case 'generate_form':
             $this->returnArray = $this->generateCustomerForm();
             break;
         default:
             break;
     }
     return $this->returnArray;
 }