PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Nette/Application/Responses/RedirectingResponse.php

https://github.com/DocX/nette
PHP | 88 lines | 25 code | 23 blank | 40 comment | 0 complexity | f20a67a766c52831bb7147417ca8f82e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Nette Framework
  4. *
  5. * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  6. *
  7. * This source file is subject to the "Nette license" that is bundled
  8. * with this package in the file license.txt.
  9. *
  10. * For more information please see http://nettephp.com
  11. *
  12. * @copyright Copyright (c) 2004, 2009 David Grudl
  13. * @license http://nettephp.com/license Nette license
  14. * @link http://nettephp.com
  15. * @category Nette
  16. * @package Nette\Application
  17. */
  18. /*namespace Nette\Application;*/
  19. require_once dirname(__FILE__) . '/../../Object.php';
  20. require_once dirname(__FILE__) . '/../../Application/IPresenterResponse.php';
  21. /**
  22. * Redirects to new request.
  23. *
  24. * @author David Grudl
  25. * @copyright Copyright (c) 2004, 2009 David Grudl
  26. * @package Nette\Application
  27. */
  28. class RedirectingResponse extends /*Nette\*/Object implements IPresenterResponse
  29. {
  30. /** @var string */
  31. private $uri;
  32. /** @var int */
  33. private $code;
  34. /**
  35. * @param string URI
  36. * @param int HTTP code 3xx
  37. */
  38. public function __construct($uri, $code = /*Nette\Web\*/IHttpResponse::S302_FOUND)
  39. {
  40. $this->uri = (string) $uri;
  41. $this->code = (int) $code;
  42. }
  43. /**
  44. * @return string
  45. */
  46. final public function getUri()
  47. {
  48. return $this->uri;
  49. }
  50. /**
  51. * @return int
  52. */
  53. final public function getCode()
  54. {
  55. return $this->code;
  56. }
  57. /**
  58. * Sends response to output.
  59. * @return void
  60. */
  61. public function send()
  62. {
  63. /*Nette\*/Environment::getHttpResponse()->redirect($this->uri, $this->code);
  64. }
  65. }