AbstractAction.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Abstract redirect/forward action class
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\App\Action;
  9. use Magento\Framework\App\RequestInterface;
  10. use Magento\Framework\App\ResponseInterface;
  11. abstract class AbstractAction implements \Magento\Framework\App\ActionInterface
  12. {
  13. /**
  14. * @var \Magento\Framework\App\RequestInterface
  15. */
  16. protected $_request;
  17. /**
  18. * @var \Magento\Framework\App\ResponseInterface
  19. */
  20. protected $_response;
  21. /**
  22. * @var \Magento\Framework\Controller\Result\RedirectFactory
  23. */
  24. protected $resultRedirectFactory;
  25. /**
  26. * @var \Magento\Framework\Controller\ResultFactory
  27. */
  28. protected $resultFactory;
  29. /**
  30. * @param Context $context
  31. */
  32. public function __construct(
  33. Context $context
  34. ) {
  35. $this->_request = $context->getRequest();
  36. $this->_response = $context->getResponse();
  37. $this->resultRedirectFactory = $context->getResultRedirectFactory();
  38. $this->resultFactory = $context->getResultFactory();
  39. }
  40. /**
  41. * Dispatch request
  42. *
  43. * @param RequestInterface $request
  44. * @return ResponseInterface
  45. */
  46. abstract public function dispatch(RequestInterface $request);
  47. /**
  48. * Retrieve request object
  49. *
  50. * @return \Magento\Framework\App\RequestInterface
  51. */
  52. public function getRequest()
  53. {
  54. return $this->_request;
  55. }
  56. /**
  57. * Retrieve response object
  58. *
  59. * @return \Magento\Framework\App\ResponseInterface
  60. */
  61. public function getResponse()
  62. {
  63. return $this->_response;
  64. }
  65. }