Source for file RedirectingResponse.php

Documentation is available at RedirectingResponse.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  7. 7:  * @license    http://nettephp.com/license  Nette license
  8. 8:  * @link       http://nettephp.com
  9. 9:  * @category   Nette
  10. 10:  * @package    Nette\Application
  11. 11:  */
  12. 12:  
  13. 13:  
  14. 14:  
  15. 15: /**
  16. 16:  * Redirects to new request.
  17. 17:  *
  18. 18:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  19. 19:  * @package    Nette\Application
  20. 20:  */
  21. 21: class RedirectingResponse extends Object implements IPresenterResponse
  22. 22: {
  23. 23:     /** @var string */
  24. 24:     private $uri;
  25. 25:  
  26. 26:     /** @var int */
  27. 27:     private $code;
  28. 28:  
  29. 29:  
  30. 30:  
  31. 31:     /**
  32. 32:      * @param  string  URI
  33. 33:      * @param  int     HTTP code 3xx
  34. 34:      */
  35. 35:     public function __construct($uri$code IHttpResponse::S302_FOUND)
  36. 36:     {
  37. 37:         $this->uri = (string) $uri;
  38. 38:         $this->code = (int) $code;
  39. 39:     }
  40. 40:  
  41. 41:  
  42. 42:  
  43. 43:     /**
  44. 44:      * @return string 
  45. 45:      */
  46. 46:     final public function getUri()
  47. 47:     {
  48. 48:         return $this->uri;
  49. 49:     }
  50. 50:  
  51. 51:  
  52. 52:  
  53. 53:     /**
  54. 54:      * @return int 
  55. 55:      */
  56. 56:     final public function getCode()
  57. 57:     {
  58. 58:         return $this->code;
  59. 59:     }
  60. 60:  
  61. 61:  
  62. 62:  
  63. 63:     /**
  64. 64:      * Sends response to output.
  65. 65:      * @return void 
  66. 66:      */
  67. 67:     public function send()
  68. 68:     {
  69. 69:         Environment::getHttpResponse()->redirect($this->uri$this->code);
  70. 70:     }
  71. 71:  
  72. 72: }