/** * Updates a product meta option. * * @param int $meta_id Product meta ID. * @param int $id Product meta option ID. * * @return void */ public function put_index($meta_id = null, $id = null) { $meta = $this->get_meta($meta_id); $option = $this->get_option($id, $meta); $validator = \Validation_Product_Meta_Option::update(); if (!$validator->run(\Input::put())) { throw new HttpBadRequestException($validator->errors()); } $data = $validator->validated(); $option = \Service_Product_Meta_Option::update($option, $data); if (!$option) { throw new HttpServerErrorException(); } $this->response($option); }
/** * Validates meta option data for a given action type. * * @param string $type The action to process (create, update). * @param array $data The data to validate. * * @return array|bool */ protected function validate_meta_option($type, $data) { if ($type == 'create') { $validator = Validation_Product_Meta_Option::create(); } else { $validator = Validation_Product_Meta_Option::update(); } if (!$validator->run($data)) { Session::set_alert('error', __('form.error')); $this->view->errors = $validator->error(); return; } return $validator->validated(); }