You are here

function CourseObjectAccessTiming::isReleased 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::isReleased()
  2. 8.2 src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::isReleased()
2 calls to CourseObjectAccessTiming::isReleased()
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 123

Class

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

Namespace

Drupal\course\Plugin\course\CourseObjectAccess

Code

function isReleased() {
  $release_date = strtotime($this
    ->getOption('release'));
  if (\Drupal::time()
    ->getRequestTime() <= $release_date) {
    $release_date_formatted = \Drupal::service('date.formatter')
      ->format($release_date, 'long');
    $this
      ->getCourseObject()
      ->setAccessMessage('not-open', t('%title will be available on %release.', array(
      '%title' => $this
        ->getCourseObject()
        ->getTitle(),
      '%release' => $release_date_formatted,
    )));
    return FALSE;
  }
  else {
    return TRUE;
  }
}