public static function Schedule::secondsToPeriod in Backup and Migrate 8.4
Same name and namespace in other branches
- 5.0.x src/Entity/Schedule.php \Drupal\backup_migrate\Entity\Schedule::secondsToPeriod()
Convert a number of of seconds into a period array.
Parameters
int $seconds:
Return value
array An array containing the period definition and the number of them. ['number' => 123, 'type' => [...]]
Throws
\BackupMigrate\Core\Exception\BackupMigrateException
2 calls to Schedule::secondsToPeriod()
- Schedule::getPeriodFormatted in src/
Entity/ Schedule.php - Return the schedule frequency formatted for display in human language.
- ScheduleForm::form in src/
Form/ ScheduleForm.php - Gets the actual form array to be built.
File
- src/
Entity/ Schedule.php, line 177
Class
- Schedule
- Defines the Schedule entity.
Namespace
Drupal\backup_migrate\EntityCode
public static function secondsToPeriod($seconds) {
foreach (array_reverse(Schedule::getPeriodTypes()) as $type) {
if ($seconds % $type['seconds'] === 0) {
return [
'number' => $seconds / $type['seconds'],
'type' => $type,
];
}
}
throw new BackupMigrateException('Invalid period.');
}