CommentsHistory.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Adminhtml\Order;
  8. use Magento\Framework\App\Action\HttpGetActionInterface;
  9. use Magento\Backend\App\Action;
  10. use Magento\Framework\App\Action\HttpPostActionInterface;
  11. use Magento\Sales\Api\OrderManagementInterface;
  12. use Magento\Sales\Api\OrderRepositoryInterface;
  13. use Psr\Log\LoggerInterface;
  14. use Magento\Sales\Controller\Adminhtml\Order as OrderAction;
  15. /**
  16. * Comments History tab, needs to be accessible by POST because of tabs mechanism.
  17. *
  18. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  19. */
  20. class CommentsHistory extends OrderAction implements HttpGetActionInterface, HttpPostActionInterface
  21. {
  22. /**
  23. * @var \Magento\Framework\View\LayoutFactory
  24. */
  25. protected $layoutFactory;
  26. /**
  27. * @param Action\Context $context
  28. * @param \Magento\Framework\Registry $coreRegistry
  29. * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  30. * @param \Magento\Framework\Translate\InlineInterface $translateInline
  31. * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
  32. * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
  33. * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
  34. * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
  35. * @param OrderManagementInterface $orderManagement
  36. * @param OrderRepositoryInterface $orderRepository
  37. * @param LoggerInterface $logger
  38. * @param \Magento\Framework\View\LayoutFactory $layoutFactory
  39. *
  40. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  41. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  42. */
  43. public function __construct(
  44. Action\Context $context,
  45. \Magento\Framework\Registry $coreRegistry,
  46. \Magento\Framework\App\Response\Http\FileFactory $fileFactory,
  47. \Magento\Framework\Translate\InlineInterface $translateInline,
  48. \Magento\Framework\View\Result\PageFactory $resultPageFactory,
  49. \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
  50. \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
  51. \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
  52. OrderManagementInterface $orderManagement,
  53. OrderRepositoryInterface $orderRepository,
  54. LoggerInterface $logger,
  55. \Magento\Framework\View\LayoutFactory $layoutFactory
  56. ) {
  57. $this->layoutFactory = $layoutFactory;
  58. parent::__construct(
  59. $context,
  60. $coreRegistry,
  61. $fileFactory,
  62. $translateInline,
  63. $resultPageFactory,
  64. $resultJsonFactory,
  65. $resultLayoutFactory,
  66. $resultRawFactory,
  67. $orderManagement,
  68. $orderRepository,
  69. $logger
  70. );
  71. }
  72. /**
  73. * Generate order history for ajax request
  74. *
  75. * @return \Magento\Framework\Controller\Result\Raw
  76. */
  77. public function execute()
  78. {
  79. $this->_initOrder();
  80. $layout = $this->layoutFactory->create();
  81. $html = $layout->createBlock(\Magento\Sales\Block\Adminhtml\Order\View\Tab\History::class)
  82. ->toHtml();
  83. $this->_translateInline->processResponseBody($html);
  84. /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
  85. $resultRaw = $this->resultRawFactory->create();
  86. $resultRaw->setContents($html);
  87. return $resultRaw;
  88. }
  89. }