omnilight\scheduling\Schedule::dueEvents PHP Method

dueEvents() public method

Get all of the events on the schedule that are due.
public dueEvents ( Application $app ) : Event[]
$app yii\base\Application
return Event[]
    public function dueEvents(Application $app)
    {
        return array_filter($this->_events, function (Event $event) use($app) {
            return $event->isDue($app);
        });
    }

Usage Example

コード例 #1
0
 public function actionRun()
 {
     $this->importScheduleFile();
     $events = $this->schedule->dueEvents(\Yii::$app);
     foreach ($events as $event) {
         $this->stdout('Running scheduled command: ' . $event->getSummaryForDisplay() . "\n");
         $event->run(\Yii::$app);
     }
     if (count($events) === 0) {
         $this->stdout("No scheduled commands are ready to run.\n");
     }
 }