You are here

function CourseObjectAccessTiming::isReleased in Course 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php \Drupal\course\Plugin\course\CourseObjectAccess\CourseObjectAccessTiming::isReleased()
  2. 3.x 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
CourseObjectAccessTiming::take in src/Plugin/course/CourseObjectAccess/CourseObjectAccessTiming.php

File

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

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