Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Last active January 3, 2016 19:19
Show Gist options
  • Save amacgregor/8507273 to your computer and use it in GitHub Desktop.
Save amacgregor/8507273 to your computer and use it in GitHub Desktop.
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