You are here

function CourseObjectAccessTiming::isExpired in Course 3.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::isExpired()
  2. 8.2 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
Can the user see the object in the outline?
CourseObjectAccessTiming::take in src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php
Can the user take the object?

File

src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php, line 135

Class

CourseObjectAccessTiming
Plugin annotation @CourseObjectAccess( id = "timing", label = @Translation("Timing"), )

Namespace

Drupal\course\Plugin\course\CourseObjectAccess

Code

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;
  }
}