/**
  * @param User $user
  *
  * @return Response
  */
 protected function processForm(User $user)
 {
     $statusCode = $user->isNew() ? 201 : 204;
     $form = $this->createForm(new UserType(), $user);
     $form->handleRequest($this->getRequest());
     if ($form->isValid()) {
         $user->save();
         $response = new Response();
         $response->setStatusCode($statusCode);
         // set the `Location` header only when creating new resources
         if (201 === $statusCode) {
             $response->headers->set('Location', $this->generateUrl('acme_demo_user_get', array('id' => $user->getId()), true));
         }
         return $response;
     }
     return View::create($form, 400);
 }