public function handle($onSuccess, $onFailure, Request $request, Application $app = null)
{
$new = false;
if (is_null($app)) {
$app = new Application();
$new = true;
}
$form = $this->formfactory->create(new ApplicationType(), $app);
$form->handleRequest($request);
if ($form->isValid()) {
$this->em->persist($app);
$this->em->flush();
return $onSuccess($form, $app, $new);
}
return $onFailure($form, $app, $new);
}