Example #1
0
 /**
  * @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()));
 }
Example #2
0
 /**
  * @Security("has_role('ROLE_USER')")
  */
 public function createAction(Request $request)
 {
     $meta = new Meta();
     $form = $this->createForm(new MetaType(), $meta);
     if ($form->handleRequest($request)->isValid()) {
         $defaultBranch = new Branch();
         $defaultBranch->setBranchId("master");
         $defaultBranch->setName("Master");
         $defaultBranch->setNotes("This is a default branch, created automatically on mod creation.");
         $defaultBranch->setIsDefault(true);
         $meta->addBranch($defaultBranch);
         $meta->addUser($this->getUser());
         $em = $this->getDoctrine()->getManager();
         $em->persist($meta);
         $em->persist($defaultBranch);
         $em->flush();
         /*
         // TODO: Add proper escaping!
         $request->getSession()
               ->getFlashBag()
               ->add('success', 'New mod <strong>"'.$meta->getTitle().'" (id: '.$meta->getMetaId().')</strong> successfully created.<br/><hr/>A default branch has been created for this mod : <strong>"'.$defaultBranch->getName().'" (id: '.$defaultBranch->getBranchId().')</strong>.');
         */
         // TODO: Maybe this should be moved into a method of Meta?
         // création de l'ACL
         $aclProvider = $this->get('security.acl.provider');
         $objectIdentity = ObjectIdentity::fromDomainObject($meta);
         $acl = $aclProvider->createAcl($objectIdentity);
         // retrouve l'identifiant de sécurité de l'utilisateur actuellement connecté
         $user = $this->getUser();
         // donne accès au propriétaire
         $securityIdentity = UserSecurityIdentity::fromAccount($user);
         $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
         $aclProvider->updateAcl($acl);
         return $this->redirect($this->generateUrl('hlp_nebula_repository_branch', array('meta' => $meta, 'branch' => $defaultBranch)));
     }
     return $this->render('HLPNebulaBundle:Meta:create.html.twig', array('form' => $form->createView()));
 }
Example #3
0
 /**
  * @ParamConverter("branch", options={"mapping": {"meta": "meta", "branch": "branchId"}, "repository_method" = "findOneWithParent"})
  */
 public function privRepoAction(Branch $branch, $key)
 {
     if ($branch->isPublic() || $branch->getPrivateKey() != $key) {
         throw new NotFoundHttpException('Branch not found!');
     }
     $response = new Response($branch->getGeneratedJson());
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Example #4
0
 /**
  * Add branches
  *
  * @param \HLP\NebulaBundle\Entity\Branch $branches
  * @return Meta
  */
 public function addBranch(\HLP\NebulaBundle\Entity\Branch $branches)
 {
     $this->branches[] = $branches;
     $branches->setMeta($this);
     return $this;
 }