Example #1
0
 /**
  * Attempts to get a product from a given ID.
  *
  * @param int $id Product ID.
  *
  * @return \Model_Product
  */
 protected function get_product($id)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $product = \Service_Product::find_one($id);
     if (!$product || $product->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     return $product;
 }
Example #2
0
 /**
  * Deletes a product.
  *
  * @param int $id Product ID.
  *
  * @return void
  */
 public function delete_index($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $product = \Service_Product::find_one($id, \Seller::active());
     if (!$product || $product->seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     $deleted = \Service_Product::delete($product);
     if (!$deleted) {
         throw new HttpServerErrorException();
     }
 }