public function get($class, $connexion, array $exchangeOptions, array $queueOptions, $lazy = false)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException(
                sprintf("Producer class '%s' doesn't exist", $class)
            );
        }

        if ($lazy) {
            if (!$connexion->isConnected()) {
                $connexion->connect();
            }
        }

        // Open a new channel
        $channel = new $this->channelClass($connexion);
        $exchange = $this->createExchange($this->exchangeClass, $channel, $exchangeOptions);

        if (isset($queueOptions['name'])) {
            // create, declare queue, and bind it to exchange
            /** @var \AMQPQueue $queue */
            $queue = new $this->queueClass($channel);
            $queue->setName($queueOptions['name']);
            $queue->setArguments($queueOptions['arguments']);
            $queue->setFlags(
                ($queueOptions['passive'] ? AMQP_PASSIVE : AMQP_NOPARAM) |
                ($queueOptions['durable'] ? AMQP_DURABLE : AMQP_NOPARAM) |
                ($queueOptions['auto_delete'] ? AMQP_AUTODELETE : AMQP_NOPARAM)
            );
            $queue->declareQueue();
            $queue->bind($exchangeOptions['name']);

            // Bind the queue to some routing keys
            foreach ($queueOptions['routing_keys'] as $routingKey) {
                $queue->bind($exchangeOptions['name'], $routingKey);
            }
        }

        // Create the producer
        $producer = new $class($exchange, $exchangeOptions);

        return $producer;
    }
public function get($class, $connexion, array $exchangeOptions, array $queueOptions, $lazy = false)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException(
                sprintf("Producer class '%s' doesn't exist", $class)
            );
        }

        if ($lazy) {
            if (!$connexion->isConnected()) {
                $connexion->connect();
            }
        }

        // Open a new channel
        $channel = new $this->channelClass($connexion);
        $exchange = $this->createExchange($this->exchangeClass, $channel, $exchangeOptions);

        if (isset($queueOptions['name'])) {
            // create, declare queue, and bind it to exchange
            /** @var \AMQPQueue $queue */
            $queue = new $this->queueClass($channel);
            $queue->setName($queueOptions['name']);
            $queue->setArguments($queueOptions['arguments']);
            $queue->setFlags(
                ($queueOptions['passive'] ? AMQP_PASSIVE : AMQP_NOPARAM) |
                ($queueOptions['durable'] ? AMQP_DURABLE : AMQP_NOPARAM) |
                ($queueOptions['auto_delete'] ? AMQP_AUTODELETE : AMQP_NOPARAM)
            );
            $queue->declareQueue();
            $queue->bind($exchangeOptions['name']);

            // Bind the queue to some routing keys
            foreach ($queueOptions['routing_keys'] as $routingKey) {
                $queue->bind($exchangeOptions['name'], $routingKey);
            }
        }

        // Create the producer
        $producer = new $class($exchange, $exchangeOptions);

        return $producer;
    }
public function get ( $ class , $ connexion , array $ exchangeOptions , array $ queueOptions , $ lazy = false ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( "Producer class '%s' doesn't exist" , $ class ) ) ; } if ( $ lazy ) { if ( ! $ connexion -> isConnected ( ) ) { $ connexion -> connect ( ) ; } } // Open a new channel $ channel = new $ this -> channelClass ( $ connexion ) ; $ exchange = $ this -> createExchange ( $ this -> exchangeClass , $ channel , $ exchangeOptions ) ; if ( isset ( $ queueOptions [ 'name' ] ) ) { // create, declare queue, and bind it to exchange /** @var \AMQPQueue $queue */ $ queue = new $ this -> queueClass ( $ channel ) ; $ queue -> setName ( $ queueOptions [ 'name' ] ) ; $ queue -> setArguments ( $ queueOptions [ 'arguments' ] ) ; $ queue -> setFlags ( ( $ queueOptions [ 'passive' ] ? AMQP_PASSIVE : AMQP_NOPARAM ) | ( $ queueOptions [ 'durable' ] ? AMQP_DURABLE : AMQP_NOPARAM ) | ( $ queueOptions [ 'auto_delete' ] ? AMQP_AUTODELETE : AMQP_NOPARAM ) ) ; $ queue -> declareQueue ( ) ; $ queue -> bind ( $ exchangeOptions [ 'name' ] ) ; // Bind the queue to some routing keys foreach ( $ queueOptions [ 'routing_keys' ] as $ routingKey ) { $ queue -> bind ( $ exchangeOptions [ 'name' ] , $ routingKey ) ; } } // Create the producer $ producer = new $ class ( $ exchange , $ exchangeOptions ) ; return $ producer ; }
build the producer class.

@param string          $class           Provider class name
@param \AMQPConnection $connexion       AMQP connexion
@param array           $exchangeOptions Exchange Options
@param array           $queueOptions    Queue Options
@param bool            $lazy            Specifies if it should connect

@return Producer
build the producer class .