/** * {@inheritdoc} */ public function map(Envelope $envelope) { if (!$this->consumerPluginManager->has($envelope->getName())) { throw new ReceiverNotFoundException(sprintf('Could not find the received for %s ', $envelope->getName())); } return $this->consumerPluginManager->get($envelope->getName()); }
/** * {@inheritDoc} */ public function map(Envelope $envelope) { $receiver = $this->get($envelope->getName()); if (false == $receiver) { throw new ReceiverNotFoundException(); } if (is_callable($receiver)) { return $receiver; } return array($receiver, lcfirst($envelope->getName())); }
/** * Returns the right Receiver (callable) based on the Envelope. * * @param Envelope $envelope * @throws \InvalidArgumentException * @return array */ public function map(Envelope $envelope) { $message = $envelope->getMessage(); if (!$message instanceof BernardMessage) { throw new \InvalidArgumentException(sprintf("Routing the message %s failed due to wrong message type", $envelope->getName())); } return array($this, "routeMessage"); }
/** * @param Envelope $envelope */ protected function verifyEnvelope(Envelope $envelope) { $queue = $envelope->getName(); if (isset($this->queues[$queue])) { return; } throw new \DomainException('Unrecognized queue specified: ' . $queue); }
/** * @param Envelope $envelope * @param Exception $exception */ protected function format(Envelope $envelope, Exception $exception) { $replacements = ['{class}' => get_class($exception), '{message}' => $exception->getMessage(), '{envelope}' => $envelope->getName()]; return strtr('[bernard] caught exception {class}::{message} while processing {envelope}.', $replacements); }