You are here

public function PreviewLinkForm::resetLifetime in Preview Link 8

Resets the lifetime of the preview link.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/PreviewLinkForm.php, line 171

Class

PreviewLinkForm
Preview link form.

Namespace

Drupal\preview_link\Form

Code

public function resetLifetime(array &$form, FormStateInterface $form_state) {
  $now = $this->time
    ->getRequestTime();
  $this->entity->generated_timestamp = $now;
  $newExpiry = $now + $this->linkExpiry
    ->getLifetime();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Preview link will now expire at %time.', [
    '%time' => $this->dateFormatter
      ->format($newExpiry),
  ]));
}