Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit ba8ea17

Browse files
committed
Set isSecureArea to allow delete from ConsumerInterface::process
I would propose a long-term solution be the creation of a `consumer` area code which would allow enabling deletes through `di.xml` similar to the `adminhtml`, `webapi_rest`, `webapi_soap` https://github.com/magento/magento2/blob/7648131e42d93ab2be23efa1983702659bbbbe84/app/code/Magento/Webapi/etc/webapi_rest/di.xml#L33 Fixes #24
1 parent 8dfe26a commit ba8ea17

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/code/Magento/AsynchronousOperations/Model/MassConsumer.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\AsynchronousOperations\Model;
1010

1111
use Magento\Framework\App\ResourceConnection;
12+
use Magento\Framework\Registry;
1213
use Psr\Log\LoggerInterface;
1314
use Magento\Framework\MessageQueue\MessageLockException;
1415
use Magento\Framework\MessageQueue\ConnectionLostException;
@@ -58,6 +59,11 @@ class MassConsumer implements ConsumerInterface
5859
*/
5960
private $operationProcessor;
6061

62+
/**
63+
* @var Registry
64+
*/
65+
private $registry;
66+
6167
/**
6268
* Initialize dependencies.
6369
*
@@ -67,14 +73,16 @@ class MassConsumer implements ConsumerInterface
6773
* @param ConsumerConfigurationInterface $configuration
6874
* @param OperationProcessorFactory $operationProcessorFactory
6975
* @param LoggerInterface $logger
76+
* @param Registry $registry
7077
*/
7178
public function __construct(
7279
CallbackInvoker $invoker,
7380
ResourceConnection $resource,
7481
MessageController $messageController,
7582
ConsumerConfigurationInterface $configuration,
7683
OperationProcessorFactory $operationProcessorFactory,
77-
LoggerInterface $logger
84+
LoggerInterface $logger,
85+
Registry $registry = null
7886
) {
7987
$this->invoker = $invoker;
8088
$this->resource = $resource;
@@ -84,20 +92,26 @@ public function __construct(
8492
'configuration' => $configuration
8593
]);
8694
$this->logger = $logger;
95+
$this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance()
96+
->get(Registry::class);
8797
}
8898

8999
/**
90-
* {@inheritdoc}
100+
* @inheritdoc
91101
*/
92102
public function process($maxNumberOfMessages = null)
93103
{
104+
$this->registry->register('isSecureArea', true, true);
105+
94106
$queue = $this->configuration->getQueue();
95107

96108
if (!isset($maxNumberOfMessages)) {
97109
$queue->subscribe($this->getTransactionCallback($queue));
98110
} else {
99111
$this->invoker->invoke($queue, $maxNumberOfMessages, $this->getTransactionCallback($queue));
100112
}
113+
114+
$this->registry->unregister('isSecureArea');
101115
}
102116

103117
/**

0 commit comments

Comments
 (0)