Example #1
0
 /**
  * @param object $build
  * @return array
  */
 public function createFromBuild(Build $build, $finalise = true)
 {
     $branch = $build->getBranch();
     $meta = $branch->getMeta();
     $data = array();
     $data['type'] = $meta->getType();
     $data['id'] = $meta->getMetaId();
     $data['title'] = $meta->getTitle();
     $data['version'] = $build->getVersion();
     if ($meta->getDescription()) {
         $data['description'] = $meta->getDescription();
     }
     if ($logo = $meta->getLogo()) {
         $host = sprintf('http%s://%s', isset($_SERVER['HTTPS']) ? 's' : '', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost');
         $data['logo'] = $host . $logo->getWebPath();
     }
     if ($build->getNotes() || $meta->getNotes()) {
         $data['notes'] = trim($meta->getNotes() . "\n\n" . $build->getNotes());
     }
     if ($build->getFolder()) {
         $data['folder'] = $build->getFolder();
     }
     if (count($build->getPackages()) > 0) {
         $data['packages'] = array();
         foreach ($build->getPackages() as $package) {
             $pkg = array('name' => $package->getName(), 'status' => $package->getStatus());
             if ($package->getNotes()) {
                 $pkg['notes'] = $package->getNotes();
             }
             if (count($package->getDependencies()) > 0) {
                 $pkg['dependencies'] = array();
                 foreach ($package->getDependencies() as $dependency) {
                     $d = array('id' => $dependency->getDepId(), 'version' => $dependency->getVersion());
                     if (count($dependency->getDepPkgs()) > 0) {
                         $d['packages'] = $dependency->getDepPkgs();
                     }
                     $pkg['dependencies'][] = $d;
                 }
             }
             if (count($package->getEnvVars()) > 0) {
                 $pkg['environment'] = array();
                 foreach ($package->getEnvVars() as $envVar) {
                     $pkg['environment'][] = array('type' => $envVar->getType(), 'value' => $envVar->getValue());
                 }
             }
             if (count($package->getExecutables()) > 0) {
                 $pkg['executables'] = array();
                 foreach ($package->getExecutables() as $exe) {
                     $pkg['executables'][] = array('version' => $exe->getVersion(), 'file' => $exe->getFile(), 'debug' => $exe->getDebug());
                 }
             }
             if (count($package->getFiles()) > 0) {
                 $pkg['files'] = array();
                 foreach ($package->getFiles() as $file) {
                     $f = array('filename' => $file->getFilename(), 'is_archive' => $file->getIsArchive(), 'urls' => $file->getUrls());
                     if ($file->getDest()) {
                         $f['dest'] = (string) $file->getDest();
                     }
                     $pkg['files'][] = $f;
                 }
             }
             $data['packages'][] = $pkg;
         }
     }
     if (count($build->getActions()) > 0) {
         $data['actions'] = array();
         foreach ($build->getActions() as $i => $action) {
             $act = array('type' => $action->getType(), 'paths' => $action->getPaths(), 'glob' => $action->getGlob());
             if ('move' == $action->getType()) {
                 $act['dest'] = (string) $action->getDest();
             }
             $data['actions'][] = $act;
         }
     }
     if ($finalise) {
         return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     } else {
         return $data;
     }
 }
Example #2
0
 /**
  * @ParamConverter("build", options={"mapping": {"meta": "meta", "branch": "branch", "build": "version"}, "repository_method" = "findOneWithParents"})
  */
 public function deleteAction(Request $request, Build $build)
 {
     $branch = $build->getBranch();
     $meta = $branch->getMeta();
     if (false === $this->isGranted('EDIT', $meta)) {
         throw new AccessDeniedException('Unauthorized access!');
     }
     $form = $this->createFormBuilder()->getForm();
     if ($form->handleRequest($request)->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->remove($build);
         $em->flush();
         $request->getSession()->getFlashBag()->add('success', "Build <strong>version " . $build->getVersion() . "</strong> has been deleted.");
         return $this->redirect($this->generateUrl('hlp_nebula_repository_branch', array('meta' => $meta, 'branch' => $branch)));
     }
     return $this->render('HLPNebulaBundle:Build:delete.html.twig', array('meta' => $meta, 'branch' => $branch, 'build' => $build, 'form' => $form->createView()));
 }
Example #3
0
 /**
  * Add builds
  *
  * @param \HLP\NebulaBundle\Entity\Build $builds
  * @return Branch
  */
 public function addBuild(\HLP\NebulaBundle\Entity\Build $builds)
 {
     $this->builds[] = $builds;
     $this->nbBuilds++;
     $builds->setBranch($this);
     $this->meta->addBuild($builds);
     return $this;
 }
Example #4
0
 /**
  * Add builds
  *
  * @param \HLP\NebulaBundle\Entity\Build $builds
  * @return Meta
  */
 public function addBuild(\HLP\NebulaBundle\Entity\Build $builds)
 {
     $this->builds[] = $builds;
     $builds->setMeta($this);
     return $this;
 }