public function run(RequestInterface $request, ResponseInterface $response)
    {
        // Unused parameter
        unset($request);

        // Lock script, to ensure it can not be run twice  at the same time (before previous instance is done).
        $this->startLock();

        $climate = $this->climate();

        $processedCallback = function($success, $failures, $skipped) use ($climate) {
            if (!empty($success)) {
                $climate->green()->out(sprintf('%s emails were successfully sent.', count($success)));
            }

            if (!empty($failures)) {
                $climate->red()->out(sprintf('%s emails were not successfully sent', count($failures)));
            }

            if (!empty($skipped)) {
                $climate->dim()->out(sprintf('%s emails were skipped.', count($skipped)));
            }
        };

        $queueManager = new EmailQueueManager([
            'logger' => $this->logger,
            'queue_item_factory' => $this->queueItemFactory
        ]);
        $queueManager->setProcessedCallback($processedCallback);
        $queueManager->processQueue();

        $this->stopLock();

        return $response;
    }
public function run(RequestInterface $request, ResponseInterface $response)
    {
        // Unused parameter
        unset($request);

        // Lock script, to ensure it can not be run twice  at the same time (before previous instance is done).
        $this->startLock();

        $climate = $this->climate();

        $processedCallback = function($success, $failures, $skipped) use ($climate) {
            if (!empty($success)) {
                $climate->green()->out(sprintf('%s emails were successfully sent.', count($success)));
            }

            if (!empty($failures)) {
                $climate->red()->out(sprintf('%s emails were not successfully sent', count($failures)));
            }

            if (!empty($skipped)) {
                $climate->dim()->out(sprintf('%s emails were skipped.', count($skipped)));
            }
        };

        $queueManager = new EmailQueueManager([
            'logger' => $this->logger,
            'queue_item_factory' => $this->queueItemFactory
        ]);
        $queueManager->setProcessedCallback($processedCallback);
        $queueManager->processQueue();

        $this->stopLock();

        return $response;
    }
public function run ( RequestInterface $ request , ResponseInterface $ response ) { // Unused parameter unset ( $ request ) ; // Lock script, to ensure it can not be run twice  at the same time (before previous instance is done). $ this -> startLock ( ) ; $ climate = $ this -> climate ( ) ; $ processedCallback = function ( $ success , $ failures , $ skipped ) use ( $ climate ) { if ( ! empty ( $ success ) ) { $ climate -> green ( ) -> out ( sprintf ( '%s emails were successfully sent.' , count ( $ success ) ) ) ; } if ( ! empty ( $ failures ) ) { $ climate -> red ( ) -> out ( sprintf ( '%s emails were not successfully sent' , count ( $ failures ) ) ) ; } if ( ! empty ( $ skipped ) ) { $ climate -> dim ( ) -> out ( sprintf ( '%s emails were skipped.' , count ( $ skipped ) ) ) ; } } ; $ queueManager = new EmailQueueManager ( [ 'logger' => $ this -> logger , 'queue_item_factory' => $ this -> queueItemFactory ] ) ; $ queueManager -> setProcessedCallback ( $ processedCallback ) ; $ queueManager -> processQueue ( ) ; $ this -> stopLock ( ) ; return $ response ; }
Process all messages currently in queue.

@param  RequestInterface  $request  A PSR-7 compatible Request instance.
@param  ResponseInterface $response A PSR-7 compatible Response instance.
@return ResponseInterface
Process all messages currently in queue .