Skip to content

Instantly share code, notes, and snippets.

@emil-nasso
Created June 8, 2015 12:23
Show Gist options
  • Save emil-nasso/c58cd75f36e30c7ca474 to your computer and use it in GitHub Desktop.
Save emil-nasso/c58cd75f36e30c7ca474 to your computer and use it in GitHub Desktop.
/**
* @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