|
11 | 11 | use Magento\AsynchronousOperations\Model\ConfigInterface;
|
12 | 12 | use Magento\Framework\Communication\ConfigInterface as CommunicationConfig;
|
13 | 13 |
|
| 14 | +/** |
| 15 | + * Force change topic's defined as ServiceName:methodName from sync to async. |
| 16 | + * Topic type will be changed if topic name starts with |
| 17 | + * \Magento\AsynchronousOperations\Model\ConfigInterface::TOPIC_PREFIX |
| 18 | + * |
| 19 | + * @SuppressWarnings("unused") |
| 20 | + */ |
14 | 21 | class CompositeReader
|
15 | 22 | {
|
16 | 23 | /**
|
17 |
| - * Topics with type schema is always are sync |
18 |
| - * @see \Magento\Framework\Communication\Config\ReflectionGenerator::generateTopicConfigForServiceMethod(). |
19 |
| - * This plugin add support for topic type schema defined as ServiceName:methodName |
20 |
| - * by force changing sync type to async |
21 |
| - * but only if topic name starts with ConfigInterface::TOPIC_PREFIX, e.g. async.* |
| 24 | + * Checking communication.xml merged configuration |
| 25 | + * to find topics with names started from "async" |
| 26 | + * \Magento\AsynchronousOperations\Model\ConfigInterface::TOPIC_PREFIX |
| 27 | + * and change config attribute value "is_synchronous" to false (make async) |
| 28 | + * for this topics. |
22 | 29 | *
|
23 | 30 | * @param \Magento\Framework\Communication\Config\CompositeReader $subject
|
24 | 31 | * @param array $result
|
25 | 32 | *
|
26 | 33 | * @return array
|
27 |
| - * @SuppressWarnings(PHPMD.UnusedLocalVariable) |
28 | 34 | */
|
29 |
| - public function afterRead(\Magento\Framework\Communication\Config\CompositeReader $subject, array $result) { |
| 35 | + public function afterRead(\Magento\Framework\Communication\Config\CompositeReader $subject, array $result) |
| 36 | + { |
30 | 37 | foreach ($result[CommunicationConfig::TOPICS] as $topicName => $topicConfig) {
|
31 | 38 | if (strpos($topicName, ConfigInterface::DEFAULT_HANDLER_NAME) === 0) {
|
32 | 39 | $topicConfig[CommunicationConfig::TOPIC_IS_SYNCHRONOUS] = false;
|
33 | 40 | $result[CommunicationConfig::TOPICS][$topicName] = $topicConfig;
|
34 | 41 | }
|
35 | 42 | }
|
| 43 | + |
36 | 44 | return $result;
|
37 | 45 | }
|
38 | 46 | }
|
0 commit comments