Baikal\ViewComponentsBundle\Services\FormHandler\ApplicationFormHandler::handle PHP Method

handle() public method

public handle ( $onSuccess, $onFailure, Request $request, Baikal\ModelBundle\Entity\OAuthClient $app = null )
$request Symfony\Component\HttpFoundation\Request
$app Baikal\ModelBundle\Entity\OAuthClient
    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);
    }
ApplicationFormHandler