| @@ 12-52 (lines=41) @@ | ||
| 9 | use mcorten87\rabbitmq_api\objects\Url; |
|
| 10 | use mcorten87\rabbitmq_api\services\MqManagementConfig; |
|
| 11 | ||
| 12 | class JobBindingToExchangeCreateMapper extends BaseMapper |
|
| 13 | { |
|
| 14 | protected function mapMethod(JobBase $job) : Method |
|
| 15 | { |
|
| 16 | return new Method(Method::METHOD_POST); |
|
| 17 | } |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @param JobBindingToExchangeCreate $job |
|
| 21 | * @return Url |
|
| 22 | */ |
|
| 23 | protected function mapUrl(JobBase $job) : Url |
|
| 24 | { |
|
| 25 | return new Url('bindings/' |
|
| 26 | .urlencode($job->getVirtualHost()).'/' |
|
| 27 | .'e/' |
|
| 28 | .urlencode($job->getExchangeName()).'/' |
|
| 29 | .$job->getDestinationType().'/' |
|
| 30 | .urlencode($job->getToExchange()) |
|
| 31 | ); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param JobBindingToExchangeCreate $job |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | protected function mapConfig(JobBase $job) : array { |
|
| 39 | $body = [ |
|
| 40 | 'arguments' => [], |
|
| 41 | 'destination' => (string)$job->getToExchange(), |
|
| 42 | 'destination_type' => $job->getDestinationType(), |
|
| 43 | 'routing_key' => (string)$job->getRoutingKey(), |
|
| 44 | 'source' => (string)$job->getExchangeName(), |
|
| 45 | 'vhost' => $job->getVirtualHost(), |
|
| 46 | ]; |
|
| 47 | ||
| 48 | return array_merge(parent::mapConfig($job), [ |
|
| 49 | 'json' => $body, |
|
| 50 | ]); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 12-52 (lines=41) @@ | ||
| 9 | use mcorten87\rabbitmq_api\objects\Url; |
|
| 10 | use mcorten87\rabbitmq_api\services\MqManagementConfig; |
|
| 11 | ||
| 12 | class JobBindingToQueueCreateMapper extends BaseMapper |
|
| 13 | { |
|
| 14 | protected function mapMethod(JobBase $job) : Method |
|
| 15 | { |
|
| 16 | return new Method(Method::METHOD_POST); |
|
| 17 | } |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @param JobBindingToExchangeCreate $job |
|
| 21 | * @return Url |
|
| 22 | */ |
|
| 23 | protected function mapUrl(JobBase $job) : Url |
|
| 24 | { |
|
| 25 | return new Url('bindings/' |
|
| 26 | .urlencode($job->getVirtualHost()).'/' |
|
| 27 | .'e/' |
|
| 28 | .urlencode($job->getExchangeName()).'/' |
|
| 29 | .$job->getDestinationType().'/' |
|
| 30 | .urlencode($job->getQueueName()) |
|
| 31 | ); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param JobBindingToExchangeCreate $job |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | protected function mapConfig(JobBase $job) : array { |
|
| 39 | $body = [ |
|
| 40 | 'arguments' => [], |
|
| 41 | 'destination' => (string)$job->getQueueName(), |
|
| 42 | 'destination_type' => $job->getDestinationType(), |
|
| 43 | 'routing_key' => (string)$job->getRoutingKey(), |
|
| 44 | 'source' => (string)$job->getExchangeName(), |
|
| 45 | 'vhost' => $job->getVirtualHost(), |
|
| 46 | ]; |
|
| 47 | ||
| 48 | return array_merge(parent::mapConfig($job), [ |
|
| 49 | 'json' => $body, |
|
| 50 | ]); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||