Skip to content

Commit 59cdcec

Browse files
committed
ACPT-826
1 parent c0cdd23 commit 59cdcec

File tree

6 files changed

+30
-55
lines changed

6 files changed

+30
-55
lines changed

app/code/Magento/AsyncConfig/Controller/Adminhtml/System/Config/Save.php renamed to app/code/Magento/AsyncConfig/Plugin/Controller/System/Config/SaveAsyncConfigPlugin.php

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\AsyncConfig\Controller\Adminhtml\System\Config;
8+
namespace Magento\AsyncConfig\Plugin\Controller\System\Config;
99

1010
use Magento\AsyncConfig\Api\AsyncConfigPublisherInterface;
11-
use Magento\Framework\App\Action\HttpPostActionInterface;
11+
use Magento\Config\Controller\Adminhtml\System\Config\Save;
1212
use Magento\Framework\App\DeploymentConfig;
1313
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\Controller\Result\RedirectFactory;
1415
use Magento\Framework\Exception\FileSystemException;
1516
use Magento\Framework\Exception\LocalizedException;
1617
use Magento\Framework\Exception\RuntimeException;
18+
use Magento\Framework\Message\ManagerInterface;
1719

18-
class Save extends \Magento\Config\Controller\Adminhtml\System\Config\Save implements HttpPostActionInterface
20+
class SaveAsyncConfigPlugin
1921
{
2022
/**
2123
* @var DeploymentConfig
@@ -27,61 +29,56 @@ class Save extends \Magento\Config\Controller\Adminhtml\System\Config\Save imple
2729
*/
2830
private $asyncConfigPublisher;
2931

32+
/**
33+
* @var RedirectFactory
34+
*/
35+
private RedirectFactory $resultRedirectFactory;
36+
37+
/**
38+
* @var ManagerInterface
39+
*/
40+
private $messageManager;
41+
3042
/**
3143
* @var const
3244
*/
3345
public const ASYNC_CONFIG_OPTION_PATH = 'config/async';
3446

3547
/**
36-
* @param \Magento\Backend\App\Action\Context $context
37-
* @param \Magento\Config\Model\Config\Structure $configStructure
38-
* @param \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker
39-
* @param \Magento\Config\Model\Config\Factory $configFactory
40-
* @param \Magento\Framework\Cache\FrontendInterface $cache
41-
* @param \Magento\Framework\Stdlib\StringUtils $string
4248
* @param DeploymentConfig|null $deploymentConfig
4349
* @param AsyncConfigPublisherInterface|null $asyncConfigPublisher
4450
*/
4551
public function __construct(
46-
\Magento\Backend\App\Action\Context $context,
47-
\Magento\Config\Model\Config\Structure $configStructure,
48-
\Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker $sectionChecker,
49-
\Magento\Config\Model\Config\Factory $configFactory,
50-
\Magento\Framework\Cache\FrontendInterface $cache,
51-
\Magento\Framework\Stdlib\StringUtils $string,
5252
DeploymentConfig $deploymentConfig = null,
53-
AsyncConfigPublisherInterface $asyncConfigPublisher = null
53+
AsyncConfigPublisherInterface $asyncConfigPublisher = null,
54+
RedirectFactory $resultRedirectFactory,
55+
ManagerInterface $messageManager
5456
) {
55-
parent::__construct(
56-
$context,
57-
$configStructure,
58-
$sectionChecker,
59-
$configFactory,
60-
$cache,
61-
$string
62-
);
6357
$this->deploymentConfig = $deploymentConfig
6458
?? ObjectManager::getInstance()->get(DeploymentConfig::class);
6559
$this->asyncConfigPublisher = $asyncConfigPublisher
6660
?? ObjectManager::getInstance()->get(AsyncConfigPublisherInterface::class);
61+
$this->resultRedirectFactory = $resultRedirectFactory;
62+
$this->messageManager = $messageManager;
6763
}
6864

6965
/**
7066
* Execute Save action
7167
*
68+
* @param Save $subject
7269
* @throws LocalizedException
7370
* @throws FileSystemException
7471
* @throws RuntimeException
7572
*/
76-
public function execute()
73+
public function aroundExecute(Save $subject, callable $proceed)
7774
{
7875
if (!$this->deploymentConfig->get(self::ASYNC_CONFIG_OPTION_PATH)) {
79-
return parent::execute();
76+
return $proceed();
8077
} else {
81-
$configData = $this->getConfigData();
78+
$configData = $subject->getConfigData();
8279
$this->asyncConfigPublisher->saveConfigData($configData);
8380
$this->messageManager->addSuccess(__('Configuration changes will be applied by consumer soon.'));
84-
$this->_saveState($this->getRequest()->getPost('config_state'));
81+
$subject->_saveState($subject->getRequest()->getPost('config_state'));
8582
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
8683
$resultRedirect = $this->resultRedirectFactory->create();
8784
return $resultRedirect->setPath(

app/code/Magento/AsyncConfig/etc/adminhtml/di.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/code/Magento/AsyncConfig/etc/adminhtml/routes.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

app/code/Magento/AsyncConfig/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@
1010
type="Magento\AsyncConfig\Model\AsyncConfigPublisher" />
1111
<preference for="Magento\AsyncConfig\Api\Data\AsyncConfigMessageInterface"
1212
type="Magento\AsyncConfig\Model\Entity\AsyncConfigMessage" />
13+
<type name="Magento\Config\Controller\Adminhtml\System\Config\Save">
14+
<plugin name="save_config_async" type="Magento\AsyncConfig\Plugin\Controller\System\Config\SaveAsyncConfigPlugin"/>
15+
</type>
1316
</config>

app/code/Magento/Config/Controller/Adminhtml/System/AbstractConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _isAllowed()
8787
* @param array $configState
8888
* @return bool
8989
*/
90-
protected function _saveState($configState = [])
90+
public function _saveState($configState = [])
9191
{
9292
if (is_array($configState)) {
9393
$configState = $this->sanitizeConfigState($configState);

app/code/Magento/Config/Controller/Adminhtml/System/Config/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function filterNodes(array $configData): array
332332
* @return array
333333
* @throws LocalizedException
334334
*/
335-
protected function getConfigData()
335+
public function getConfigData()
336336
{
337337
$this->_saveSection();
338338
$section = $this->getRequest()->getParam('section');

0 commit comments

Comments
 (0)