/**
  * Handles project creation action. 
  * 
  * @param Request $request
  * 
  * @return Response
  */
 public function addAction(Request $request)
 {
     $project = new Project();
     $project->setUser($this->getUser());
     // Create the form which manages the project creation.
     $form = $this->createForm(new ProjectType(), $project);
     // Handle user submitted data.
     $form->handleRequest($request);
     // Validate the form.
     if ($form->isValid()) {
         // If the data is valid, save the newly created project.
         $data = $form->getData();
         // Set created and updated flags.
         $data->setCreated()->setUpdated();
         $doctrine = $this->getDoctrine()->getManager();
         $doctrine->persist($data);
         $doctrine->flush();
         return $this->redirectToRoute('php_sanitizer_project_index');
     }
     // Render the form.
     return $this->render('project/add.html.twig', array('form' => $form->createView()));
 }