public function createAction()
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $task = new Task();
     $form = new TaskForm('task', $task, $this->container->get('validator'), array('entity_manager' => $em));
     $form->bind($this->get('request')->get('task'));
     if ($form->isValid()) {
         $user = $this->container->get('security.context')->getUser();
         $task->setCreatedBy($user);
         $em->persist($task);
         $em->flush();
         $this->notifyNewTask($task, $user);
     }
     return $this->redirect($this->generateUrl('projects_view', array('id' => $form->getData()->getProject()->getId())));
 }
 /**
  * Add task
  *
  * @param Application\ChiaBundle\Entity\Task $task
  */
 public function addTask(\Application\ChiaBundle\Entity\Task $task)
 {
     $task->setProject($this);
     $this->tasks[] = $task;
 }