-
-
Save norberttech/4016ea5421d48fafe1fd 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
<?php | |
class ProductController | |
{ | |
public function createProductAction(Request $request) | |
{ | |
$command = new CreateProductCommand(); | |
$form = $this->createForm(new ProductType(), $command); | |
$form->handle($request); | |
if ($form->isValid()) { | |
$this->get('command_bus')->handle($command); | |
$product = $this->get('product.repository')->getLastAddedProduct(); | |
return new RedirectResponse(sprintf('/some/url/%s', (string) $product->getId())); | |
} | |
return ['form' => $form->createView()]; | |
} | |
} | |
class CreateProductCommand | |
{ | |
public $name; | |
public $priceAmout; | |
public $priceCurreny; | |
public $description; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment