You are here

public function TimeMachine::setTime in Preview Link 2.x

Same name and namespace in other branches
  1. 2.0.x tests/modules/preview_link_test_time/src/TimeMachine.php \Drupal\preview_link_test_time\TimeMachine::setTime()

Sets time.

Parameters

\DateTimeInterface $dateTime: Sets the time.

File

tests/modules/preview_link_test_time/src/TimeMachine.php, line 66

Class

TimeMachine
Service used to simulate time.

Namespace

Drupal\preview_link_test_time

Code

public function setTime(\DateTimeInterface $dateTime) {
  if ($dateTime instanceof \DateTime) {
    $dateTime = \DateTimeImmutable::createFromMutable($dateTime);
  }
  $this->state
    ->set('preview_link_test_time_machine', $dateTime);
}