setOutputHandler($this->listener = $listener); } /** * Execute the console command. * * @return void */ public function handle() { // We need to get the right queue for the connection which is set in the queue // configuration file for the application. We will pull it based on the set // connection being run for the queue operation currently being executed. $queue = $this->getQueue( $connection = $this->input->getArgument('connection') ); $this->listener->listen( $connection, $queue, $this->gatherOptions() ); } /** * Get the name of the queue connection to listen on. * * @param string $connection * @return string */ protected function getQueue($connection) { $connection = $connection ?: $this->laravel['config']['queue.default']; return $this->input->getOption('queue') ?: $this->laravel['config']->get( "queue.connections.{$connection}.queue", 'default' ); } /** * Get the listener options for the command. * * @return \Illuminate\Queue\ListenerOptions */ protected function gatherOptions() { return new ListenerOptions( $this->option('env'), $this->option('delay'), $this->option('memory'), $this->option('timeout'), $this->option('sleep'), $this->option('tries'), $this->option('force') ); } /** * Set the options on the queue listener. * * @param \Illuminate\Queue\Listener $listener * @return void */ protected function setOutputHandler(Listener $listener) { $listener->setOutputHandler(function ($type, $line) { $this->output->write($line); }); } }