class PreviewLinkSessionExistsAccessCheck in Preview Link 2.x
Same name and namespace in other branches
- 2.0.x src/Access/PreviewLinkSessionExistsAccessCheck.php \Drupal\preview_link\Access\PreviewLinkSessionExistsAccessCheck
Checks whether the user has a session.
Hierarchy
- class \Drupal\preview_link\Access\PreviewLinkSessionExistsAccessCheck implements AccessInterface
Expanded class hierarchy of PreviewLinkSessionExistsAccessCheck
1 string reference to 'PreviewLinkSessionExistsAccessCheck'
1 service uses PreviewLinkSessionExistsAccessCheck
File
- src/
Access/ PreviewLinkSessionExistsAccessCheck.php, line 16
Namespace
Drupal\preview_link\AccessView source
class PreviewLinkSessionExistsAccessCheck implements AccessInterface {
/**
* The session configuration.
*
* @var \Drupal\Core\Session\SessionConfigurationInterface
*/
protected $sessionConfiguration;
/**
* Constructs a new PreviewLinkSessionExistsAccessCheck.
*
* @param \Drupal\Core\Session\SessionConfigurationInterface $sessionConfiguration
* The session configuration.
*/
public function __construct(SessionConfigurationInterface $sessionConfiguration) {
$this->sessionConfiguration = $sessionConfiguration;
}
/**
* Checks whether the user has a session.
*
* @param \Symfony\Component\HttpFoundation\Request|null $request
* The request, if available.
*
* @return \Drupal\Core\Access\AccessResultInterface
* Whether the user has a session.
*/
public function access(Request $request = NULL) : AccessResultInterface {
return AccessResult::allowedIf($request ? $this->sessionConfiguration
->hasSession($request) : FALSE)
->addCacheContexts([
'session.exists',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PreviewLinkSessionExistsAccessCheck:: |
protected | property | The session configuration. | |
PreviewLinkSessionExistsAccessCheck:: |
public | function | Checks whether the user has a session. | |
PreviewLinkSessionExistsAccessCheck:: |
public | function | Constructs a new PreviewLinkSessionExistsAccessCheck. |