SubmitPage.inc 909 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class SubmitPage implements IPage
  3. {
  4. public static function getInstance()
  5. {
  6. return new SubmitPage(new Rest(), new Header(), BusinessLogicProcessor::getInstance());
  7. }
  8. private $rest;
  9. private $header;
  10. private $businessLogicProcessor;
  11. private function __construct(Rest $rest, Header $header, BusinessLogicProcessor $businessLogicProcessor)
  12. {
  13. $this->rest = $rest;
  14. $this->header = $header;
  15. $this->businessLogicProcessor = $businessLogicProcessor;
  16. }
  17. public function process()
  18. {
  19. try
  20. {
  21. $id = $this->rest->get('id');
  22. }
  23. catch (RestException $e)
  24. {
  25. return "Page ID not specified";
  26. }
  27. $result = $this->businessLogicProcessor->processSubmit($id);
  28. if(isset($result['error']))
  29. {
  30. $_SESSION['error'] = $result;
  31. }
  32. $redirectUrl = "/";
  33. if(isset($result['redirect']))
  34. {
  35. $redirectUrl = $result['redirect'];
  36. }
  37. $this->header->location($redirectUrl);
  38. }
  39. }