Edit.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 as HttpGetActionInterface;
  9. class Edit extends AbstractScopeConfig implements HttpGetActionInterface
  10. {
  11. /**
  12. * @var \Magento\Framework\View\Result\PageFactory
  13. */
  14. protected $resultPageFactory;
  15. /**
  16. * @param \Magento\Backend\App\Action\Context $context
  17. * @param \Magento\Config\Model\Config\Structure $configStructure
  18. * @param \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker
  19. * @param \Magento\Config\Model\Config $backendConfig
  20. * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
  21. */
  22. public function __construct(
  23. \Magento\Backend\App\Action\Context $context,
  24. \Magento\Config\Model\Config\Structure $configStructure,
  25. \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker,
  26. \Magento\Config\Model\Config $backendConfig,
  27. \Magento\Framework\View\Result\PageFactory $resultPageFactory
  28. ) {
  29. parent::__construct($context, $configStructure, $sectionChecker, $backendConfig);
  30. $this->resultPageFactory = $resultPageFactory;
  31. }
  32. /**
  33. * Edit configuration section
  34. *
  35. * @return \Magento\Framework\App\ResponseInterface|void
  36. */
  37. public function execute()
  38. {
  39. $current = $this->getRequest()->getParam('section');
  40. $website = $this->getRequest()->getParam('website');
  41. $store = $this->getRequest()->getParam('store');
  42. /** @var $section \Magento\Config\Model\Config\Structure\Element\Section */
  43. $section = $this->_configStructure->getElement($current);
  44. if ($current && !$section->isVisible($website, $store)) {
  45. /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
  46. $redirectResult = $this->resultRedirectFactory->create();
  47. return $redirectResult->setPath('adminhtml/*/', ['website' => $website, 'store' => $store]);
  48. }
  49. /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
  50. $resultPage = $this->resultPageFactory->create();
  51. $resultPage->setActiveMenu('Magento_Config::system_config');
  52. $resultPage->getLayout()->getBlock('menu')->setAdditionalCacheKeyInfo([$current]);
  53. $resultPage->addBreadcrumb(__('System'), __('System'), $this->getUrl('*\/system'));
  54. $resultPage->getConfig()->getTitle()->prepend(__('Configuration'));
  55. return $resultPage;
  56. }
  57. }