Exemplo n.º 1
0
 /**
  * @Route("/client/{idClient}/job/{idJob}", name="editJob")
  * @Method("GET")
  * @Template()
  */
 public function editJobAction(Request $request, $idClient, $idJob)
 {
     if ('new' === $idJob) {
         $job = new Job();
         $client = $this->getDoctrine()->getRepository('BinovoElkarBackupBundle:Client')->find($idClient);
         if (null == $client) {
             throw $this->createNotFoundException($this->trans('Unable to find Client entity:') . $idClient);
         }
         $job->setClient($client);
         $job->setOwner($this->get('security.context')->getToken()->getUser());
     } else {
         $job = $this->getDoctrine()->getRepository('BinovoElkarBackupBundle:Job')->find($idJob);
     }
     $form = $this->createForm(new JobType(), $job, array('translator' => $this->get('translator')));
     $this->info('View client %clientid%, job %jobid%', array('%clientid%' => $idClient, '%jobid%' => $idJob), array('link' => $this->generateJobRoute($idJob, $idClient)));
     $this->getDoctrine()->getManager()->flush();
     return $this->render('BinovoElkarBackupBundle:Default:job.html.twig', array('form' => $form->createView()));
 }