Guest User

Untitled

a guest
Jan 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public function editAction()
  2. {
  3. // Create the form.
  4. $form = new JobForm();
  5.  
  6. // Get post ID.
  7. $jobId = $this->params()->fromRoute('id', -1);
  8.  
  9. // Find existing job in the database.
  10. $jobs = $this->entityManager->getRepository(Jobs::class)
  11. ->findOneById($jobId);
  12. if ($jobs == null) {
  13. $this->getResponse()->setStatusCode(404);
  14. return;
  15. }
  16.  
  17. // Check whether this job is a POST request.
  18. if ($this->getRequest()->isPost()) {
  19.  
  20. // Get POST data.
  21. $data = $this->params()->fromPost();
  22.  
  23. // Fill form with data.
  24. $form->setData($data);
  25. if ($form->isValid()) {
  26.  
  27. // Get validated form data.
  28. $data = $form->getData();
  29.  
  30. // Use job manager service to add new post to database.
  31. $this->jobManager->updateJob( $jobs, $data);
  32.  
  33. // Redirect the user to "backups" page.
  34. return $this->redirect()->toRoute('backups');
  35. }
  36. } else {...}
Add Comment
Please, Sign In to add comment