Skip to content

Instantly share code, notes, and snippets.

@nikita2206
Created January 20, 2014 08:34
Show Gist options
  • Save nikita2206/8516804 to your computer and use it in GitHub Desktop.
Save nikita2206/8516804 to your computer and use it in GitHub Desktop.
class ProductController {
protected $productFactory;
public function __construct(ProductFactory $productFactory)
{
$this->productFactory = $productFactory;
}
public function create($product_type)
{
// Some post data validation logic here
// Now we need to instantiate our product
$product = $this->productFactory->build($product_type, $post['sku'], $post['name'])
// Do something with the post data and save the product
...
return $product->getType();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment