Exemplo n.º 1
0
 /**
  * Attempts to get a customer product option from a given ID.
  *
  * @param int $id Customer product option ID.
  *
  * @return Model_Customer_Product_Option
  */
 protected function get_option($id)
 {
     $option = Service_Customer_Product_Option::find_one(array('id' => $id, 'status' => 'all'));
     if (!$option || $option->customer->seller != Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $option;
 }
Exemplo n.º 2
0
 /**
  * Gets one or more customer product options.
  *
  * @param int $customer_id Customer ID.
  * @param int $id          Product option ID.
  *
  * @return void
  */
 public function get_index($customer_id = null, $id = null)
 {
     if (!$customer_id) {
         throw new HttpNotFoundException();
     }
     $customer = \Service_Customer::find_one($customer_id);
     if (!$customer || $customer->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     if (!$id) {
         $products = \Service_Customer_Product_Option::find(array('customer' => $customer));
     } else {
         $products = \Service_Customer_Product_Option::find_one($id);
         if (!$products || $products->customer != $customer) {
             throw new HttpNotFoundException();
         }
     }
     $this->response($products);
 }