class LinkExpiry in Preview Link 8
Calculates link expiry time.
Hierarchy
- class \Drupal\preview_link\LinkExpiry
Expanded class hierarchy of LinkExpiry
1 file declares its use of LinkExpiry
- PreviewLinkForm.php in src/
Form/ PreviewLinkForm.php
1 string reference to 'LinkExpiry'
1 service uses LinkExpiry
File
- src/
LinkExpiry.php, line 10
Namespace
Drupal\preview_linkView source
class LinkExpiry {
/**
* Default expiry time in days.
*
* @var int
*/
const DEFAULT_EXPIRY_DAYS = 7;
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* LinkExpiry constructor.
*
* @param \Drupal\Core\State\StateInterface $state
* The state service.
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* Calculates default lifetime of a preview link.
*
* @return int
* Preview link in seconds.
*/
public function getLifetime() {
$days = $this->state
->get('preview_link_expiry_days', static::DEFAULT_EXPIRY_DAYS);
return $days * 86400;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LinkExpiry:: |
protected | property | The state service. | |
LinkExpiry:: |
constant | Default expiry time in days. | ||
LinkExpiry:: |
public | function | Calculates default lifetime of a preview link. | |
LinkExpiry:: |
public | function | LinkExpiry constructor. |