/** * @param Request $request * @return array * * @Extra\Route( "/select", * name="weaving_the_web_dashboard_settings_select_remote" * ) * @Extra\Method({"GET", "POST"}) * @Extra\Template("WeavingTheWebDashboardBundle:Settings:Remote/Select/_form.html.twig") */ public function selectRemoteAction(Request $request) { $currentRoute = $this->getCurrentRoute(); /** @var \WeavingTheWeb\Bundle\DashboardBundle\Entity\Remote $remote */ $remote = $this->remoteRepository->findOneby(['selected' => true, 'user' => $this->getUser()]); $data = null; if (!is_null($remote)) { $data = ['remotes' => $remote]; } $this->selectRemoteType->setUser($this->getUser()); $form = $this->formFactory->create($this->selectRemoteType, $data, ['action' => $currentRoute]); if ($this->isFormSubmitted($form, $request)) { if ($form->isValid()) { /** @var \WeavingTheWeb\Bundle\DashboardBundle\Entity\Remote $submittedRemote */ $submittedRemote = $form->get('remotes')->getData(); // Unselect the previously selected remote if (!is_null($data)) { $remote->unselect(); $this->updateRemoteSelection($remote); } if (is_null($submittedRemote)) { $messageKey = 'empty_selection'; } else { $submittedRemote->select(); $this->updateRemoteSelection($submittedRemote); $messageKey = 'success'; } $successMessage = $this->translator->trans('remote.select_remote.' . $messageKey, [], 'remote'); $this->addFlashMessages([$successMessage], 'select_remote_info'); return new RedirectResponse($currentRoute); } else { $this->handleFormErrors($form, 'select_remote'); } } return ['select_remote_form' => $form->createView()]; }
/** * @return array * * @Extra\Route( * "/", * name="weaving_the_web_dashboard_job_show_jobs" * ) * @Extra\Template("WeavingTheWebDashboardBundle:Dashboard/Job:_list.html.twig") */ public function showJobsAction() { $remote = $this->remoteRepository->findOneBy(['user' => $this->getUser(), 'selected' => true]); return ['active_menu_item' => 'dashboard_jobs', 'remote' => $remote]; }