/**
  * @param OutgoingPhysicalMessageContext $context
  * @param callable                       $next
  */
 public function invoke($context, callable $next)
 {
     $mutatorIds = $this->mutatorRegistry->getOutgoingPhysicalMessageMutatorIds();
     if (empty($mutatorIds)) {
         $next();
         return;
     }
     $physicalMessage = $context->getMessage();
     $mutatorContext = new OutgoingPhysicalMessageMutationContext($physicalMessage->getBody(), $physicalMessage->getHeaders());
     foreach ($mutatorIds as $mutatorId) {
         /** @var OutgoingPhysicalMessageMutatorInterface $mutator */
         $mutator = $context->getBuilder()->build($mutatorId);
         $mutator->mutateOutgoing($mutatorContext);
     }
     $physicalMessage->replaceBody($mutatorContext->getBody());
     $physicalMessage->replaceHeaders($mutatorContext->getHeaders());
     $next();
 }
 /**
  * @param OutgoingLogicalMessageContext $context
  * @param callable                      $next
  */
 public function invoke($context, callable $next)
 {
     $mutatorIds = $this->mutatorRegistry->getOutgoingLogicalMessageMutatorIds();
     if (empty($mutatorIds)) {
         $next();
         return;
     }
     $logicalMessage = $context->getMessage();
     $messageInstance = $logicalMessage->getMessageInstance();
     $mutatorContext = new OutgoingLogicalMessageMutationContext($messageInstance, $context->getHeaders());
     foreach ($mutatorIds as $mutatorId) {
         /** @var OutgoingLogicalMessageMutatorInterface $mutator */
         $mutator = $context->getBuilder()->build($mutatorId);
         $mutator->mutateOutgoing($mutatorContext);
     }
     if ($mutatorContext->hasMessageChanged()) {
         $logicalMessage->updateInstance($mutatorContext->getMessage());
     }
     $context->replaceHeaders($mutatorContext->getHeaders());
     $next();
 }
예제 #3
0
 /**
  * @param string $mutatorContainerId
  */
 public function registerOutgoingPhysicalMessageMutator($mutatorContainerId)
 {
     $this->messageMutatorRegistry->registerOutgoingPhysicalMessageMutator($mutatorContainerId);
 }