| @@ 49-71 (lines=23) @@ | ||
| 46 | * |
|
| 47 | * @return RedirectResponse|Response |
|
| 48 | */ |
|
| 49 | public function addAction(Request $request) |
|
| 50 | { |
|
| 51 | $cronManager = new CronManager(); |
|
| 52 | $cron = new Cron(); |
|
| 53 | $this->addFlash('message', $cronManager->getOutput()); |
|
| 54 | $this->addFlash('error', $cronManager->getError()); |
|
| 55 | $form = $this->createForm(new CronType(), $cron); |
|
| 56 | ||
| 57 | $form->handleRequest($request); |
|
| 58 | if ($form->isValid()) { |
|
| 59 | $cronManager->add($cron); |
|
| 60 | $this->addFlash('message', $cronManager->getOutput()); |
|
| 61 | $this->addFlash('error', $cronManager->getError()); |
|
| 62 | ||
| 63 | return $this->redirect($this->generateUrl('foa_cron_index')); |
|
| 64 | } |
|
| 65 | ||
| 66 | return $this->render('FOACronBundle:Dashboard:index.html.twig', [ |
|
| 67 | 'crons' => $cronManager->getCrons(), |
|
| 68 | 'raw' => $cronManager->getRaw(), |
|
| 69 | 'form' => $form->createView(), |
|
| 70 | ]); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Edit a cron |
|
| @@ 80-103 (lines=24) @@ | ||
| 77 | * |
|
| 78 | * @return RedirectResponse|Response |
|
| 79 | */ |
|
| 80 | public function editAction($id) |
|
| 81 | { |
|
| 82 | $cronManager = new CronManager(); |
|
| 83 | $this->addFlash('message', $cronManager->getOutput()); |
|
| 84 | $this->addFlash('error', $cronManager->getError()); |
|
| 85 | $cron = $cronManager->getById($id); |
|
| 86 | $form = $this->createForm(new CronType(), $cron); |
|
| 87 | ||
| 88 | $request = $this->get('request'); |
|
| 89 | $form->handleRequest($request); |
|
| 90 | if ($form->isValid()) { |
|
| 91 | $cronManager->write(); |
|
| 92 | ||
| 93 | $this->addFlash('message', $cronManager->getOutput()); |
|
| 94 | $this->addFlash('error', $cronManager->getError()); |
|
| 95 | ||
| 96 | return $this->redirect($this->generateUrl('foa_cron_index')); |
|
| 97 | } |
|
| 98 | ||
| 99 | return $this->render('FOACronBundle:Dashboard:edit.html.twig', [ |
|
| 100 | 'id' => $id, |
|
| 101 | 'form' => $form->createView(), |
|
| 102 | ]); |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Wake up a cron from the cron table |
|