AbstractHelper.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ hdJu3rr7BgJDAVkYjTvYG/ZRNRdup1qDbnUhOCimuXM=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.0
  11. */
  12. /**
  13. * controller action helper abstract class
  14. */
  15. namespace Cube\Controller\Action\Helper;
  16. use Cube\Controller\Front,
  17. Cube\Controller\Action\AbstractAction;
  18. abstract class AbstractHelper
  19. {
  20. /**
  21. *
  22. * action object
  23. *
  24. * @var \Cube\Controller\Action\AbstractAction
  25. */
  26. protected $_action;
  27. /**
  28. *
  29. * get action object
  30. *
  31. * @return \Cube\Controller\Action\AbstractAction
  32. */
  33. public function getAction()
  34. {
  35. return $this->_action;
  36. }
  37. /**
  38. *
  39. * set action object
  40. *
  41. * @param \Cube\Controller\Action\AbstractAction $action
  42. * @return \Cube\Controller\Action\Helper\AbstractHelper
  43. */
  44. public function setAction(AbstractAction $action)
  45. {
  46. $this->_action = $action;
  47. return $this;
  48. }
  49. /**
  50. *
  51. * get request object from action controller or front controller
  52. *
  53. * @return \Cube\Controller\Request\AbstractRequest
  54. */
  55. public function getRequest()
  56. {
  57. $action = $this->getAction();
  58. if ($action === null) {
  59. $action = Front::getInstance();
  60. }
  61. return $action->getRequest();
  62. }
  63. /**
  64. *
  65. * get response object from action controller or front controller
  66. *
  67. * @return \Cube\Controller\Response\ResponseInterface
  68. */
  69. public function getResponse()
  70. {
  71. $action = $this->getAction();
  72. if ($action === null) {
  73. $action = Front::getInstance();
  74. }
  75. return $action->getResponse();
  76. }
  77. }