1
|
|
|
<?php |
2
|
|
|
namespace PSB\Core\Pipeline; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use PSB\Core\Pipeline\Incoming\IncomingContext; |
6
|
|
|
use PSB\Core\Pipeline\Outgoing\OutgoingLogicalMessage; |
7
|
|
|
use PSB\Core\Pipeline\Outgoing\StageContext\OutgoingPublishContext; |
8
|
|
|
use PSB\Core\Pipeline\Outgoing\StageContext\OutgoingReplyContext; |
9
|
|
|
use PSB\Core\Pipeline\Outgoing\StageContext\OutgoingSendContext; |
10
|
|
|
use PSB\Core\Pipeline\Outgoing\StageContext\SubscribeContext; |
11
|
|
|
use PSB\Core\Pipeline\Outgoing\StageContext\UnsubscribeContext; |
12
|
|
|
use PSB\Core\PublishOptions; |
13
|
|
|
use PSB\Core\ReplyOptions; |
14
|
|
|
use PSB\Core\SendOptions; |
15
|
|
|
use PSB\Core\SubscribeOptions; |
16
|
|
|
use PSB\Core\UnsubscribeOptions; |
17
|
|
|
|
18
|
|
|
class BusOperationsContextFactory |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @param object $message |
22
|
|
|
* @param PublishOptions $options |
23
|
|
|
* @param PipelineStageContext $parentContext |
24
|
|
|
* |
25
|
|
|
* @return OutgoingPublishContext |
26
|
|
|
*/ |
27
|
2 |
View Code Duplication |
public function createPublishContext( |
28
|
|
|
$message, |
29
|
|
|
PublishOptions $options, |
30
|
|
|
PipelineStageContext $parentContext |
31
|
|
|
) { |
32
|
2 |
|
return new OutgoingPublishContext( |
33
|
2 |
|
new OutgoingLogicalMessage($message), |
34
|
2 |
|
$options, |
35
|
2 |
|
$parentContext instanceof IncomingContext ? $parentContext->getIncomingPhysicalMessage() : null, |
36
|
2 |
|
$parentContext instanceof IncomingContext ? $parentContext->getPendingTransportOperations() : null, |
37
|
2 |
|
$parentContext |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param object $message |
43
|
|
|
* @param SendOptions $options |
44
|
|
|
* @param PipelineStageContext $parentContext |
45
|
|
|
* |
46
|
|
|
* @return OutgoingSendContext |
47
|
|
|
*/ |
48
|
2 |
View Code Duplication |
public function createSendContext( |
49
|
|
|
$message, |
50
|
|
|
SendOptions $options, |
51
|
|
|
PipelineStageContext $parentContext |
52
|
|
|
) { |
53
|
2 |
|
return new OutgoingSendContext( |
54
|
2 |
|
new OutgoingLogicalMessage($message), |
55
|
2 |
|
$options, |
56
|
2 |
|
$parentContext instanceof IncomingContext ? $parentContext->getIncomingPhysicalMessage() : null, |
57
|
2 |
|
$parentContext instanceof IncomingContext ? $parentContext->getPendingTransportOperations() : null, |
58
|
2 |
|
$parentContext |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param object $message |
64
|
|
|
* @param ReplyOptions $options |
65
|
|
|
* @param IncomingContext $parentContext |
66
|
|
|
* |
67
|
|
|
* @return OutgoingReplyContext |
68
|
|
|
*/ |
69
|
1 |
|
public function createReplyContext( |
70
|
|
|
$message, |
71
|
|
|
ReplyOptions $options, |
72
|
|
|
IncomingContext $parentContext |
73
|
|
|
) { |
74
|
1 |
|
return new OutgoingReplyContext( |
75
|
1 |
|
new OutgoingLogicalMessage($message), |
76
|
1 |
|
$options, |
77
|
1 |
|
$parentContext->getIncomingPhysicalMessage(), |
78
|
1 |
|
$parentContext->getPendingTransportOperations(), |
79
|
1 |
|
$parentContext |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $eventFqcn |
85
|
|
|
* @param SubscribeOptions $options |
86
|
|
|
* @param PipelineStageContext $parentContext |
87
|
|
|
* |
88
|
|
|
* @return SubscribeContext |
89
|
|
|
*/ |
90
|
1 |
|
public function createSubscribeContext($eventFqcn, SubscribeOptions $options, PipelineStageContext $parentContext) |
91
|
|
|
{ |
92
|
1 |
|
return new SubscribeContext($eventFqcn, $options, $parentContext); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $eventFqcn |
97
|
|
|
* @param UnsubscribeOptions $options |
98
|
|
|
* @param PipelineStageContext $parentContext |
99
|
|
|
* |
100
|
|
|
* @return UnsubscribeContext |
101
|
|
|
*/ |
102
|
1 |
|
public function createUnsubscribeContext( |
103
|
|
|
$eventFqcn, |
104
|
|
|
UnsubscribeOptions $options, |
105
|
|
|
PipelineStageContext $parentContext |
106
|
|
|
) { |
107
|
1 |
|
return new UnsubscribeContext($eventFqcn, $options, $parentContext); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|