class TimeChanger in Content locking (anti-concurrent editing) 8
Same name and namespace in other branches
- 8.2 modules/content_lock_timeout/tests/modules/content_lock_timeout_test/src/TimeChanger.php \Drupal\content_lock_timeout_test\TimeChanger
This is a datetime.time service for testing only.
@package Drupal\Tests\content_lock_timeout\Functional
Hierarchy
- class \Drupal\Component\Datetime\Time implements TimeInterface- class \Drupal\content_lock_timeout_test\TimeChanger
 
Expanded class hierarchy of TimeChanger
File
- modules/content_lock_timeout/ tests/ modules/ content_lock_timeout_test/ src/ TimeChanger.php, line 12 
Namespace
Drupal\content_lock_timeout_testView source
class TimeChanger extends Time {
  protected $overwrittenTime = NULL;
  /**
   * {@inheritdoc}
   */
  public function getCurrentTime() {
    $time = \Drupal::keyValue('time')
      ->get('time', NULL);
    if (!empty($time)) {
      return $time;
    }
    return parent::getCurrentTime();
  }
  /**
   * Forward current time to the given timestamp.
   *
   * @param int $time
   *   New time to set.
   */
  public function setCurrentTime($time) {
    \Drupal::keyValue('time')
      ->set('time', $time);
  }
  /**
   * Reset the current time to the real time.
   */
  public function resetCurrentTime() {
    \Drupal::keyValue('time')
      ->delete('time');
  }
  /**
   * {@inheritdoc}
   */
  public function getRequestTime() {
    $time = \Drupal::keyValue('time')
      ->get('time', NULL);
    if (!empty($time)) {
      return $time;
    }
    return parent::getRequestTime();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| Time:: | protected | property | The request stack. | |
| Time:: | public | function | Returns the current system time with microsecond precision. Overrides TimeInterface:: | |
| Time:: | public | function | Returns the timestamp for the current request with microsecond precision. Overrides TimeInterface:: | |
| Time:: | public | function | Constructs a Time object. | |
| TimeChanger:: | protected | property | ||
| TimeChanger:: | public | function | Returns the current system time as an integer. Overrides Time:: | |
| TimeChanger:: | public | function | Returns the timestamp for the current request. Overrides Time:: | |
| TimeChanger:: | public | function | Reset the current time to the real time. | |
| TimeChanger:: | public | function | Forward current time to the given timestamp. | 
