示例#1
0
 /**
  * Creates a seller.
  *
  * @return void
  */
 public function post_index()
 {
     $validator = \Validation_Seller::create();
     if (!$validator->run()) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $seller = \Service_Seller::create($data['name'], $data);
     if (!$seller) {
         throw new HttpServerErrorException();
     }
     $this->response($seller);
 }
示例#2
0
 /**
  * POST Index action.
  *
  * @return void
  */
 public function post_index()
 {
     $this->get_index();
     $validator = Validation_Seller::create();
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     if (!($seller = Service_Seller::create($data['name'], $data))) {
         Session::set_alert('error', 'There was an error adding the seller.');
         return;
     }
     Response::redirect($seller->link('switch'));
 }