12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- class SubmitPage implements IPage
- {
- public static function getInstance()
- {
- return new SubmitPage(new Rest(), new Header(), BusinessLogicProcessor::getInstance());
- }
- private $rest;
- private $header;
- private $businessLogicProcessor;
- private function __construct(Rest $rest, Header $header, BusinessLogicProcessor $businessLogicProcessor)
- {
- $this->rest = $rest;
- $this->header = $header;
- $this->businessLogicProcessor = $businessLogicProcessor;
- }
- public function process()
- {
- try
- {
- $id = $this->rest->get('id');
- }
- catch (RestException $e)
- {
- return "Page ID not specified";
- }
-
- $result = $this->businessLogicProcessor->processSubmit($id);
-
- if(isset($result['error']))
- {
- $_SESSION['error'] = $result;
- }
-
- $redirectUrl = "/";
- if(isset($result['redirect']))
- {
- $redirectUrl = $result['redirect'];
- }
-
- $this->header->location($redirectUrl);
- }
- }
|