/** * @ParamConverter("branch", options={"mapping": {"meta": "meta", "branch": "branchId"}, "repository_method" = "findOneWithParent"}) * @Security("is_granted('EDIT', branch.getMeta())") */ public function createAction(Request $request, Branch $branch) { $build = new Build(); // Get the latest build in this branch. $latest = $this->getDoctrine()->getManager()->getRepository('HLPNebulaBundle:Build')->findSingleBuild($branch->getMeta()->getMetaId(), $branch->getBranchid()); if ($latest === null) { $build->setVersion('1.0.0'); } else { $build->setVersion($latest->getVersion()); } $form = $this->createForm(new BuildType(), $build); $form->handleRequest($request); if ($form->isValid()) { $build->setState(Build::WAITING); $branch->addBuild($build); $em = $this->getDoctrine()->getManager(); $em->persist($build); $em->flush(); // $request->getSession() // ->getFlashBag() // ->add('success', 'New build <strong>version '.$build->getVersion().'</strong> successfully created.'); return $this->redirect($this->generateUrl('hlp_nebula_process', array('meta' => $build->getMeta(), 'branch' => $build->getBranch(), 'build' => $build))); } if (!$form->isValid() && $request->isMethod('POST')) { $request->getSession()->getFlashBag()->add('error', '<strong>Invalid data !</strong> Please check this form again.'); } return $this->render('HLPNebulaBundle:Build:create.html.twig', array('meta' => $branch->getMeta(), 'branch' => $branch, 'form' => $form->createView(), 'upload_url' => $this->container->get('hlpnebula.knossos')->getUploadURL())); }