<?php
namespace Illuminate\Console\Scheduling;
use Illuminate\Console\Command;
// namespace is very good,like a dir or a folder
class ScheduleRunCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'schedule:run';// ScheduleRunCommand
// The console command name.
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the scheduled commands';
// The console command description
// a description about the command in console
/**
* The schedule instance.
*
* @var \Illuminate\Console\Scheduling\Schedule
*/
protected $schedule;// a string to store the instance of the Schedule
/**
* Create a new command instance.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function __construct(Schedule $schedule)
{
$this->schedule = $schedule;
parent::__construct();
}// Create a new command instance.
// a big __set
// set the Schedule to the variable
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$events = $this->schedule->dueEvents($this->laravel);// get the events
$eventsRan = 0;// maybe the run times
foreach ($events as $event) {// run every events
if (! $event->filtersPass($this->laravel)) {
continue;
}// check the events
$this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
// write a line get the wrong message
$event->run($this->laravel);
++$eventsRan;// this the times
}
if (count($events) === 0 || $eventsRan === 0) {
$this->info('No scheduled commands are ready to run.');
}// info always be used like a log
}//Execute the command
}
每天laravel-20160713|ScheduleRunCommand
最新推荐文章于 2024-02-03 15:35:24 发布