State.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Config\Controller\Adminhtml\System\Config;
  8. use Magento\Framework\App\Action\HttpGetActionInterface;
  9. use Magento\Framework\App\Action\HttpPostActionInterface;
  10. /**
  11. * Save current state of open tabs. GET is allowed for legacy reasons.
  12. */
  13. class State extends AbstractScopeConfig implements HttpPostActionInterface, HttpGetActionInterface
  14. {
  15. /**
  16. * @var \Magento\Framework\Controller\Result\RawFactory
  17. */
  18. protected $resultRawFactory;
  19. /**
  20. * @param \Magento\Backend\App\Action\Context $context
  21. * @param \Magento\Config\Model\Config\Structure $configStructure
  22. * @param \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker
  23. * @param \Magento\Config\Model\Config $backendConfig
  24. * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
  25. */
  26. public function __construct(
  27. \Magento\Backend\App\Action\Context $context,
  28. \Magento\Config\Model\Config\Structure $configStructure,
  29. \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker,
  30. \Magento\Config\Model\Config $backendConfig,
  31. \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
  32. ) {
  33. parent::__construct($context, $configStructure, $sectionChecker, $backendConfig);
  34. $this->resultRawFactory = $resultRawFactory;
  35. }
  36. /**
  37. * Save fieldset state through AJAX
  38. *
  39. * @return \Magento\Framework\Controller\Result\Raw
  40. */
  41. public function execute()
  42. {
  43. if ($this->getRequest()->getParam('isAjax')
  44. && $this->getRequest()->getParam('container') != ''
  45. && $this->getRequest()->getParam('value') != ''
  46. ) {
  47. $configState = [$this->getRequest()->getParam('container') => $this->getRequest()->getParam('value')];
  48. $this->_saveState($configState);
  49. /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
  50. $resultRaw = $this->resultRawFactory->create();
  51. return $resultRaw->setContents('success');
  52. }
  53. }
  54. }