34 private $communicationConfig;
39 private $queueNameBuilder;
50 CommunicationConfig $communicationConfig,
54 $this->communicationConfig = $communicationConfig;
55 $this->queueNameBuilder = $queueNameBuilder;
65 if (
null === $this->mappedData) {
66 $this->mappedData = [];
67 foreach ($this->configData->get() as $exchange) {
69 foreach ($exchange[
'bindings'] as $binding) {
70 if ($binding[
'destinationType'] ===
'queue') {
71 $queueItems = $this->createQueueItems($binding[
'destination'], $binding[
'topic'],
$connection);
72 $this->mappedData = array_merge($this->mappedData, $queueItems);
77 return $this->mappedData;
88 private function createQueueItems($name, $topic, $connection)
91 $synchronousTopics = [];
93 if (strpos($topic,
'*') !==
false || strpos($topic,
'#') !==
false) {
94 $synchronousTopics = $this->matchSynchronousTopics($topic);
95 }
elseif ($this->isSynchronousTopic($topic)) {
96 $synchronousTopics[$topic] = $topic;
99 foreach ($synchronousTopics as $topicName) {
100 $callbackQueueName = $this->queueNameBuilder->getQueueName($topicName);
102 'name' => $callbackQueueName,
105 'autoDelete' =>
false,
114 'autoDelete' =>
false,
127 private function isSynchronousTopic($topicName)
130 $topic = $this->communicationConfig->getTopic($topicName);
131 $isSync = (bool)$topic[CommunicationConfig::TOPIC_IS_SYNCHRONOUS];
132 }
catch (LocalizedException $e) {
133 throw new LocalizedException(
new Phrase(
'Error while checking if topic is synchronous'));
144 private function matchSynchronousTopics($wildcard)
146 $topicDefinitions = array_filter(
147 $this->communicationConfig->getTopics(),
149 return (
bool)
$item[CommunicationConfig::TOPIC_IS_SYNCHRONOUS];
154 $pattern = $this->buildWildcardPattern($wildcard);
155 foreach (array_keys($topicDefinitions) as $topicName) {
156 if (preg_match(
$pattern, $topicName)) {
157 $topics[$topicName] = $topicName;
169 private function buildWildcardPattern($wildcardKey)
171 $pattern =
'/^' . str_replace(
'.',
'\.', $wildcardKey);
174 $pattern .= strpos($wildcardKey,
'#') === strlen($wildcardKey) ?
'/' :
'$/';
elseif(isset( $params[ 'redirect_parent']))
__construct(Data $configData, CommunicationConfig $communicationConfig, ResponseQueueNameBuilder $queueNameBuilder)
if(!isset($_GET['name'])) $name