Created
June 8, 2015 12:23
-
-
Save emil-nasso/c58cd75f36e30c7ca474 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
/** | |
* @Route("/mini-api") | |
* @Method("POST") | |
*/ | |
class ApiController extends Controller | |
{ | |
/** | |
* @Route("/customer/create.{_format}", name="mini-api_customer_create", requirements={ | |
"_format" : "json" | |
* }) | |
* @param Request $request | |
* @return JsonResponse | |
*/ | |
function createCustomerAction(Request $request) | |
{ | |
$form = $this->createFormBuilder() | |
->add('customerName', 'text', ['constraints' => [new NotBlank(), new Length(['min' => 3, 'max' => 128])]]) | |
->getForm(); | |
$form->handleRequest($request); | |
return new JsonResponse($form->getData()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment