Example #1
0
 public function stopAction(Request $request, $id)
 {
     /** @var \AppBundle\Model\Entity\Job $job */
     $job = $this->em->getRepository(Job::class)->find($id);
     ControllerHelper::checkEntityExists($job);
     $message = ['type' => 'job_stop_request', 'job_id' => $job->getId()];
     $this->producer->publish(json_encode($message));
     return new RedirectResponse($request->headers->get('referer'));
 }
Example #2
0
 public function removeAction($id)
 {
     $project = $this->em->getRepository(Project::class)->find($id);
     ControllerHelper::checkEntityExists($project);
     $this->em->remove($project);
     $this->em->flush();
     $this->flashHelper->setFlash('info', 'Project successfully removed');
     return new RedirectResponse($this->router->generate('main_page'));
 }
Example #3
0
 public function indexAction(Request $request)
 {
     $repository = $this->em->getRepository(Job::class);
     $lastJob = $repository->latestJob();
     if ($lastJob !== null) {
         $project = $lastJob->getBuild()->getProject();
         return ControllerHelper::forward($request, $this->httpKernel, 'controller.project:viewAction', ['id' => $project->getId()]);
     }
     return $this->templating->renderResponse(self::INDEX_TEMPLATE);
 }
Example #4
0
 public function createAction(Request $request, $id)
 {
     /** @var Project $project */
     $project = $this->em->getRepository(Project::class)->find($id);
     ControllerHelper::checkEntityExists($project);
     switch ($project->getRepositoryType()) {
         case RepositoryType::GITHUB:
             return ControllerHelper::forward($request, $this->httpKernel, 'controller.build.github:createAction', ['id' => $project->getId()]);
         case RepositoryType::GITLAB:
             return ControllerHelper::forward($request, $this->httpKernel, 'controller.build.gitlab:createAction', ['id' => $project->getId()]);
         default:
             throw new \LogicException(sprintf("Unknown project type: %s", $project->getRepositoryType()));
     }
 }
Example #5
0
 public function createAction(Request $request, $id)
 {
     /** @var Project $project */
     $project = $this->em->getRepository(Project::class)->find($id);
     ControllerHelper::checkEntityExists($project);
     $form = $this->formFactory->create(GithubBuildForm::class, null, ['project' => $project]);
     $form->handleRequest($request);
     $build = null;
     if ($form->isSubmitted()) {
         if ($form->isValid()) {
             $buildData = $form->getData();
             $build = $this->buildCreator->createBuild($project, $this->githubService->normalizeBuildData($project->getServerIdentity(), $buildData));
             $this->flashHelper->setFlash('success', 'Build successfully created');
             return new RedirectResponse($this->router->generate('build_view', ['id' => $build->getId()]));
         } else {
             $this->flashHelper->setFlash('danger', 'Error saving build');
         }
     }
     return $this->templating->renderResponse('build/create_github.html.twig', ['form' => $form->createView(), 'entity' => $build, 'project' => $project]);
 }