public function searchAction(Request $request, Application $app) { $formCreate = new SearchClientFormProvider($app); $form = $formCreate->create(); $form->handleRequest($request); if ($request->getMethod() === 'POST' && $form->isValid()) { $mongoDbService = new MongoDbService(new MongoDbRepository($app['config'])); $data = $request->request->get('form'); $clientEntity = new ClientEntity(); $clientEntity->setFirstName($data['first_name']); $clientEntity->setLastName($data['last_name']); $clientEntity->setEmail($data['email']); $clientEntity->setAge($data['age']); $search = $mongoDbService->search($clientEntity); return new Response(json_encode($search->toArray()), 200, ['Content-Type' => 'application/json']); } return new Response(json_encode(['result' => false]), 503, ['Content-Type' => 'application/json']); }
public function searchAction(Application $app) { $formSearch = new SearchClientFormProvider($app); $form = $formSearch->create(); return new Response($app['twig']->render('search.html.twit', ['form' => $form->createView()])); }