public function generateSchedulesForJob(Aoe_Scheduler_Model_Job $job)
    {
        if (!$job->canBeScheduled()) {
            return $this;
        }

        $exists = array();
        foreach ($this->getPendingSchedules(array($job->getJobCode()), array()) as $schedule) {
            /* @var Aoe_Scheduler_Model_Schedule $schedule */
            $exists[$schedule->getJobCode() . '/' . $schedule->getScheduledAt()] = 1;
        }

        $now = time();
        $scheduleAheadFor = Mage::getStoreConfig(Mage_Cron_Model_Observer::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
        $timeAhead = $now + $scheduleAheadFor;

        $schedule = Mage::getModel('cron/schedule'); /* @var $schedule Aoe_Scheduler_Model_Schedule */
        $schedule->initializeFromJob($job);
        $schedule->setScheduledReason(Aoe_Scheduler_Model_Schedule::REASON_GENERATESCHEDULES);

        for ($time = $now + 60; $time < $timeAhead; $time += 60) {
            $ts = strftime('%Y-%m-%d %H:%M:00', $time);
            if (!empty($exists[$job->getJobCode().'/'.$ts])) {
                // already scheduled
                continue;
            }
            if (!$schedule->trySchedule($time)) {
                // time does not match cron expression
                continue;
            }
            $schedule->unsScheduleId()->save();
        }

        return $this;
    }
public function generateSchedulesForJob(Aoe_Scheduler_Model_Job $job)
    {
        if (!$job->canBeScheduled()) {
            return $this;
        }

        $exists = array();
        foreach ($this->getPendingSchedules(array($job->getJobCode()), array()) as $schedule) {
            /* @var Aoe_Scheduler_Model_Schedule $schedule */
            $exists[$schedule->getJobCode() . '/' . $schedule->getScheduledAt()] = 1;
        }

        $now = time();
        $scheduleAheadFor = Mage::getStoreConfig(Mage_Cron_Model_Observer::XML_PATH_SCHEDULE_AHEAD_FOR)*60;
        $timeAhead = $now + $scheduleAheadFor;

        $schedule = Mage::getModel('cron/schedule'); /* @var $schedule Aoe_Scheduler_Model_Schedule */
        $schedule->initializeFromJob($job);
        $schedule->setScheduledReason(Aoe_Scheduler_Model_Schedule::REASON_GENERATESCHEDULES);

        for ($time = $now + 60; $time < $timeAhead; $time += 60) {
            $ts = strftime('%Y-%m-%d %H:%M:00', $time);
            if (!empty($exists[$job->getJobCode().'/'.$ts])) {
                // already scheduled
                continue;
            }
            if (!$schedule->trySchedule($time)) {
                // time does not match cron expression
                continue;
            }
            $schedule->unsScheduleId()->save();
        }

        return $this;
    }
public function generateSchedulesForJob ( Aoe_Scheduler_Model_Job $ job ) { if ( ! $ job -> canBeScheduled ( ) ) { return $ this ; } $ exists = array ( ) ; foreach ( $ this -> getPendingSchedules ( array ( $ job -> getJobCode ( ) ) , array ( ) ) as $ schedule ) { /* @var Aoe_Scheduler_Model_Schedule $schedule */ $ exists [ $ schedule -> getJobCode ( ) . '/' . $ schedule -> getScheduledAt ( ) ] = 1 ; } $ now = time ( ) ; $ scheduleAheadFor = Mage :: getStoreConfig ( Mage_Cron_Model_Observer :: XML_PATH_SCHEDULE_AHEAD_FOR ) * 60 ; $ timeAhead = $ now + $ scheduleAheadFor ; $ schedule = Mage :: getModel ( 'cron/schedule' ) ; /* @var $schedule Aoe_Scheduler_Model_Schedule */ $ schedule -> initializeFromJob ( $ job ) ; $ schedule -> setScheduledReason ( Aoe_Scheduler_Model_Schedule :: REASON_GENERATESCHEDULES ) ; for ( $ time = $ now + 60 ; $ time < $ timeAhead ; $ time += 60 ) { $ ts = strftime ( '%Y-%m-%d %H:%M:00' , $ time ) ; if ( ! empty ( $ exists [ $ job -> getJobCode ( ) . '/' . $ ts ] ) ) { // already scheduled continue ; } if ( ! $ schedule -> trySchedule ( $ time ) ) { // time does not match cron expression continue ; } $ schedule -> unsScheduleId ( ) -> save ( ) ; } return $ this ; }
Generate jobs for config information

@param Aoe_Scheduler_Model_Job $job

@return $this
Generate jobs for config information