Last active
January 3, 2016 19:19
-
-
Save amacgregor/8507273 to your computer and use it in GitHub Desktop.
Product controller updated with factory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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