function CourseObjectAccessTiming::take 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::take()
- 3.x src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::take()
Overrides CourseObjectAccessPluginBase::take
1 call to CourseObjectAccessTiming::take()
- CourseObjectAccessTiming::view in src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessTiming.php
File
- src/
Plugin/ course/ CourseObjectAccess/ CourseObjectAccessTiming.php, line 30
Class
- CourseObjectAccessTiming
- Plugin annotation @CourseObjectAccess( id = "timing", label = @Translation("Timing"), )
Namespace
Drupal\course\Plugin\course\CourseObjectAccessCode
function take($account) {
$time = \Drupal::time()
->getRequestTime();
if ($this
->getOption('duration')) {
if ($this
->getCourseObject()
->getFulfillment($account)
->getOption('date_started')) {
$duration_end = $this
->getCourseObject()
->getFulfillment($account)
->getOption('date_started') + $this
->getOption('duration');
if ($time > $duration_end) {
$duration_end_h = \Drupal::service('date.formatter')
->format($duration_end, 'long');
$this
->getCourseObject()
->setAccessMessage('duration-expired', t('Your enrollment in this activity expired on %date.', array(
'%date' => $duration_end_h,
)));
return FALSE;
}
}
}
$released = $this
->isReleased();
$expired = $this
->isExpired();
return $released && !$expired;
}