Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Product controller updated with factory
<?php
class ProductController {
public function create($product_type)
{
// Some post data validation logic here
// Now we need to instantiate our product
$product = 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
You can’t perform that action at this time.