Commit 47ab85ba authored by Mat's avatar Mat

APIBundle, la route et le controller pour la fonction create qui va avec le form

parent 33700f24
......@@ -53,4 +53,26 @@ class OwnerController extends MasterAPIController
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function createAction(Request $request)
{
$owner = new Owner();
$form = $this->createForm(OwnerAPIType::class, $owner);
$form->handleRequest($owner);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($owner);
$em->flush();
return $this->api($owner);
}
return $this->api($form);
}
}
......@@ -20,6 +20,13 @@ api_image_update:
_controller: APIBundle:Image:update
methods: [ POST ]
api_owner_create:
path: /owner/add
defaults:
_controller: APIBundle:Owner:create
methods: [ POST ]
##
## Note:
##
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment