/**
  * Creates a new Client entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Client();
     $entity->setUser($this->getUser());
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('clients'));
     }
     return $this->render('WebRobotFreelanceBundle:Client:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
 }
 /**
  * @param Request $request
  * @return Response|Client
  */
 public function putClientAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $check = $em->getRepository('WebRobotFreelanceBundle:Client')->findOneBy(['name' => $request->get('name'), 'user' => $this->getUser()]);
     if (!$check) {
         $client = new Client();
         $client->setName($request->get('name'));
         $client->setUser($this->getUser());
         $em->persist($client);
         $em->flush();
         return $client;
     }
     $response = new Response('The client already exists', Response::HTTP_ACCEPTED);
     return $response;
 }