Pantheon\Terminus\Collections\Backups::setBackupSchedule PHP Method

setBackupSchedule() public method

Sets an environment's regular backup schedule
public setBackupSchedule ( array $options = ['day' => null, 'hour' => null] ) : Workflow
$options array Elements as follow: string day A day of the week integer hour Hour of the day to run the backups at, 0 = 00:00 23 = 23:00
return Workflow
    public function setBackupSchedule(array $options = ['day' => null, 'hour' => null])
    {
        $backup_hour = isset($options['hour']) && !is_null($options['hour']) ? $options['hour'] : null;
        $day_number = isset($options['day']) ? $this->getDayNumber($options['day']) : rand(0, 6);
        $schedule = [];
        for ($day = 0; $day < 7; $day++) {
            $schedule[$day] = (object) ['hour' => $backup_hour, 'ttl' => null];
            $schedule[$day]->ttl = $day == $day_number ? self::WEEKLY_BACKUP_TTL : self::DAILY_BACKUP_TTL;
        }
        $schedule = (object) $schedule;
        $workflow = $this->getEnvironment()->getWorkflows()->create('change_backup_schedule', ['params' => ['backup_schedule' => $schedule]]);
        return $workflow;
    }