public function ActiveHours::findNextTime in SMS Framework 8
Same name and namespace in other branches
- 2.x modules/sms_user/src/ActiveHours.php \Drupal\sms_user\ActiveHours::findNextTime()
- 2.1.x modules/sms_user/src/ActiveHours.php \Drupal\sms_user\ActiveHours::findNextTime()
Determine the next valid active hours date range for a user.
Parameters
\Drupal\user\UserInterface $user: A user entity.
string $now: A time or strtotime() relative string localised to the users timezone. Defaults to current time for the user.
Return value
\Drupal\sms_user\ActiveHoursDates|false A date pair, or FALSE if no next date could be determined.
Overrides ActiveHoursInterface::findNextTime
1 call to ActiveHours::findNextTime()
- ActiveHours::delaySmsMessage in modules/
sms_user/ src/ ActiveHours.php - Delay a SMS message if active hours require it to be delayed.
File
- modules/
sms_user/ src/ ActiveHours.php, line 75
Class
- ActiveHours
- Defines the user active hours service.
Namespace
Drupal\sms_userCode
public function findNextTime(UserInterface $user, $now = 'now') {
$timezone = $user
->getTimeZone();
$now = new DrupalDateTime($now, $timezone);
foreach ($this
->getRanges($timezone) as $date) {
// The end date may have already passed.
if ($now > $date
->getEndDate()) {
continue;
}
return $date;
}
return FALSE;
}