Created
January 20, 2014 08:34
-
-
Save nikita2206/8516804 to your computer and use it in GitHub Desktop.
This file contains 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
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