function CourseObjectAccessTiming::isExpired in Course 8.3
Same name and namespace in other branches
- 8.2 src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::isExpired()
- 3.x src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::isExpired()
2 calls to CourseObjectAccessTiming::isExpired()
- CourseObjectAccessTiming::see in src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessTiming.php - CourseObjectAccessTiming::take in src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessTiming.php
File
- src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessTiming.php, line 133
Class
- CourseObjectAccessTiming
- Plugin annotation @CourseObjectAccess( id = "timing", label = @Translation("Timing"), )
Namespace
Drupal\course\Plugin\course\CourseObjectAccessCode
function isExpired() {
$expiration_date = strtotime($this
->getOption('expiration'));
if ($this
->getOption('expiration') && \Drupal::time()
->getRequestTime() > $expiration_date) {
$expiration_date_formatted = \Drupal::service('date.formatter')
->format($expiration_date, 'long');
$this
->getCourseObject()
->setAccessMessage('closed', t('%title closed on %expiration.', array(
'%title' => $this
->getCourseObject()
->getTitle(),
'%expiration' => $expiration_date_formatted,
)));
return TRUE;
}
else {
return FALSE;
}
}