public function getQueue(Debugger $debugger)
    {
        /** @var \Indatus\Dispatcher\Queue $queue */
        $queue = App::make('Indatus\Dispatcher\Queue');

        /** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
        foreach ($this->getScheduledCommands() as $command) {
            /** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */
            $scheduler = App::make('Indatus\Dispatcher\Scheduling\Schedulable');

            //could be multiple schedules based on arguments
            $schedules = $command->schedule($scheduler);
            if (!is_array($schedules)) {
                $schedules = [$schedules];
            }

            $willBeRun = false;
            foreach ($schedules as $schedule) {
                if (($schedule instanceof Schedulable) === false) {
                    $msg = 'Schedule for "'.$command->getName().'" is not an instance of Schedulable';
                    throw new \InvalidArgumentException($msg);
                }

                if ($this->isDue($schedule)) {
                    /** @var \Indatus\Dispatcher\QueueItem $queueItem */
                    $queueItem = App::make('Indatus\Dispatcher\QueueItem');

                    $queueItem->setCommand($command);
                    $queueItem->setScheduler($schedule);

                    if ($queue->add($queueItem)) {
                        $willBeRun = true;
                    }
                }
            }

            //it didn't run, so record that it didn't run
            if ($willBeRun === false) {
                $debugger->commandNotRun($command, 'No schedules were due');
            }
        }

        return $queue;
    }
public function getQueue(Debugger $debugger)
    {
        /** @var \Indatus\Dispatcher\Queue $queue */
        $queue = App::make('Indatus\Dispatcher\Queue');

        /** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
        foreach ($this->getScheduledCommands() as $command) {
            /** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */
            $scheduler = App::make('Indatus\Dispatcher\Scheduling\Schedulable');

            //could be multiple schedules based on arguments
            $schedules = $command->schedule($scheduler);
            if (!is_array($schedules)) {
                $schedules = [$schedules];
            }

            $willBeRun = false;
            foreach ($schedules as $schedule) {
                if (($schedule instanceof Schedulable) === false) {
                    $msg = 'Schedule for "'.$command->getName().'" is not an instance of Schedulable';
                    throw new \InvalidArgumentException($msg);
                }

                if ($this->isDue($schedule)) {
                    /** @var \Indatus\Dispatcher\QueueItem $queueItem */
                    $queueItem = App::make('Indatus\Dispatcher\QueueItem');

                    $queueItem->setCommand($command);
                    $queueItem->setScheduler($schedule);

                    if ($queue->add($queueItem)) {
                        $willBeRun = true;
                    }
                }
            }

            //it didn't run, so record that it didn't run
            if ($willBeRun === false) {
                $debugger->commandNotRun($command, 'No schedules were due');
            }
        }

        return $queue;
    }
public function getQueue ( Debugger $ debugger ) { /** @var \Indatus\Dispatcher\Queue $queue */ $ queue = App :: make ( 'Indatus\Dispatcher\Queue' ) ; /** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */ foreach ( $ this -> getScheduledCommands ( ) as $ command ) { /** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */ $ scheduler = App :: make ( 'Indatus\Dispatcher\Scheduling\Schedulable' ) ; //could be multiple schedules based on arguments $ schedules = $ command -> schedule ( $ scheduler ) ; if ( ! is_array ( $ schedules ) ) { $ schedules = [ $ schedules ] ; } $ willBeRun = false ; foreach ( $ schedules as $ schedule ) { if ( ( $ schedule instanceof Schedulable ) === false ) { $ msg = 'Schedule for "' . $ command -> getName ( ) . '" is not an instance of Schedulable' ; throw new \ InvalidArgumentException ( $ msg ) ; } if ( $ this -> isDue ( $ schedule ) ) { /** @var \Indatus\Dispatcher\QueueItem $queueItem */ $ queueItem = App :: make ( 'Indatus\Dispatcher\QueueItem' ) ; $ queueItem -> setCommand ( $ command ) ; $ queueItem -> setScheduler ( $ schedule ) ; if ( $ queue -> add ( $ queueItem ) ) { $ willBeRun = true ; } } } //it didn't run, so record that it didn't run if ( $ willBeRun === false ) { $ debugger -> commandNotRun ( $ command , 'No schedules were due' ) ; } } return $ queue ; }
Get all commands that are due to be run

@param Debugger $debugger

@throws \InvalidArgumentException
@return \Indatus\Dispatcher\Queue
Get all commands that are due to be run