| @@ 12-43 (lines=32) @@ | ||
| 9 | use mcorten87\rabbitmq_api\objects\Url; |
|
| 10 | use mcorten87\rabbitmq_api\services\MqManagementConfig; |
|
| 11 | ||
| 12 | class JobExchangeCreateMapper extends BaseMapper |
|
| 13 | { |
|
| 14 | protected function mapMethod(JobBase $job) : Method |
|
| 15 | { |
|
| 16 | return new Method(Method::METHOD_PUT); |
|
| 17 | } |
|
| 18 | ||
| 19 | protected function mapUrl(JobBase $job) : Url |
|
| 20 | { |
|
| 21 | return new Url('exchanges/'.urlencode($job->getVirtualHost()).'/'.urlencode($job->getExchangeName())); |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param JobExchangeCreate $job |
|
| 26 | * @return array |
|
| 27 | */ |
|
| 28 | protected function mapConfig(JobBase $job) : array { |
|
| 29 | $body = [ |
|
| 30 | 'auto_delete' => $job->isAutoDelete(), |
|
| 31 | 'durable' => $job->isDurable(), |
|
| 32 | 'arguments' => [] |
|
| 33 | ]; |
|
| 34 | ||
| 35 | foreach ($job->getArguments() as $argument) { |
|
| 36 | $body['arguments'][$argument->getArgumentName()] = $argument->getValue(); |
|
| 37 | }; |
|
| 38 | ||
| 39 | return array_merge(parent::mapConfig($job), [ |
|
| 40 | 'json' => $body, |
|
| 41 | ]); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||
| @@ 12-43 (lines=32) @@ | ||
| 9 | use mcorten87\rabbitmq_api\objects\Url; |
|
| 10 | use mcorten87\rabbitmq_api\services\MqManagementConfig; |
|
| 11 | ||
| 12 | class JobQueueCreateMapper extends BaseMapper |
|
| 13 | { |
|
| 14 | protected function mapMethod(JobBase $job) : Method |
|
| 15 | { |
|
| 16 | return new Method(Method::METHOD_PUT); |
|
| 17 | } |
|
| 18 | ||
| 19 | protected function mapUrl(JobBase $job) : Url |
|
| 20 | { |
|
| 21 | return new Url('queues/'.urlencode($job->getVirtualHost()).'/'.urlencode($job->getQueueName())); |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param JobQueueCreate $job |
|
| 26 | * @return array |
|
| 27 | */ |
|
| 28 | protected function mapConfig(JobBase $job) : array { |
|
| 29 | $body = [ |
|
| 30 | 'auto_delete' => $job->isAutoDelete(), |
|
| 31 | 'durable' => $job->isDurable(), |
|
| 32 | 'arguments' => [] |
|
| 33 | ]; |
|
| 34 | ||
| 35 | foreach ($job->getArguments() as $argument) { |
|
| 36 | $body['arguments'][$argument->getArgumentName()] = $argument->getValue(); |
|
| 37 | }; |
|
| 38 | ||
| 39 | return array_merge(parent::mapConfig($job), [ |
|
| 40 | 'json' => $body, |
|
| 41 | ]); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||