Crunz\Console\Command\ScheduleRunCommand::execute PHP Method

execute() protected method

Executes the current command
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : null | integer
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
return null | integer null or 0 if everything went fine, or an error code
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->arguments = $input->getArguments();
        $this->options = $input->getOptions();
        $files = $this->collectFiles($this->arguments['source']);
        if (!count($files)) {
            $output->writeln('<comment>No task found! Please check your source path.</comment>');
            exit;
        }
        // List of schedules
        $schedules = [];
        foreach ($files as $file) {
            $schedule = (require $file->getRealPath());
            if (!$schedule instanceof Schedule) {
                continue;
            }
            // We keep the events which are due and dismiss the rest.
            $schedule->events($schedule->dueEvents());
            if (count($schedule->events())) {
                $schedules[] = $schedule;
            }
        }
        if (!count($schedules)) {
            $output->writeln('<comment>No event is due!</comment>');
            exit;
        }
        // Running the events
        (new EventRunner())->handle($schedules);
    }