|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OldSound\RabbitMqBundle\RabbitMq; |
|
4
|
|
|
|
|
5
|
|
|
class Binding extends BaseAmqp |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var string |
|
9
|
|
|
*/ |
|
10
|
|
|
protected $exchange; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $destination; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var bool |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $destinationIsExchange = false; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $routingKey; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var bool |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $nowait = false; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $arguments; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getExchange() |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->exchange; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $exchange |
|
47
|
|
|
*/ |
|
48
|
2 |
|
public function setExchange($exchange) |
|
49
|
|
|
{ |
|
50
|
2 |
|
$this->exchange = $exchange; |
|
51
|
2 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getDestination() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->destination; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $destination |
|
63
|
|
|
*/ |
|
64
|
2 |
|
public function setDestination($destination) |
|
65
|
|
|
{ |
|
66
|
2 |
|
$this->destination = $destination; |
|
67
|
2 |
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return bool |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getDestinationIsExchange() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->destinationIsExchange; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param bool $destinationIsExchange |
|
79
|
|
|
*/ |
|
80
|
1 |
|
public function setDestinationIsExchange($destinationIsExchange) |
|
81
|
|
|
{ |
|
82
|
1 |
|
$this->destinationIsExchange = $destinationIsExchange; |
|
83
|
1 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getRoutingKey() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->routingKey; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param string $routingKey |
|
95
|
|
|
*/ |
|
96
|
2 |
|
public function setRoutingKey($routingKey) |
|
97
|
|
|
{ |
|
98
|
2 |
|
$this->routingKey = $routingKey; |
|
99
|
2 |
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return boolean |
|
103
|
|
|
*/ |
|
104
|
|
|
public function isNowait() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->nowait; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param boolean $nowait |
|
111
|
|
|
*/ |
|
112
|
|
|
public function setNowait($nowait) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->nowait = $nowait; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return array |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getArguments() |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->arguments; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @param array $arguments |
|
127
|
|
|
*/ |
|
128
|
|
|
public function setArguments($arguments) |
|
129
|
|
|
{ |
|
130
|
|
|
$this->arguments = $arguments; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* create bindings |
|
136
|
|
|
* |
|
137
|
|
|
* @return void |
|
138
|
|
|
*/ |
|
139
|
2 |
|
public function setupFabric() |
|
140
|
|
|
{ |
|
141
|
2 |
|
$method = ($this->destinationIsExchange) ? 'exchange_bind' : 'queue_bind'; |
|
142
|
2 |
|
$channel = $this->getChannel(); |
|
143
|
2 |
|
call_user_func( |
|
144
|
2 |
|
array($channel, $method), |
|
145
|
2 |
|
$this->destination, |
|
146
|
2 |
|
$this->exchange, |
|
147
|
2 |
|
$this->routingKey, |
|
148
|
2 |
|
$this->nowait, |
|
149
|
2 |
|
$this->arguments |
|
150
|
|
|
); |
|
151
|
2 |
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|