class TokenGetter in Access unpublished 8
Service to handle the current token.
Hierarchy
- class \Drupal\access_unpublished\TokenGetter implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of TokenGetter
3 files declare their use of TokenGetter
- AccessUnpublishedRouteLoad.php in src/
Plugin/ GraphQL/ DataProducer/ AccessUnpublishedRouteLoad.php - AccessUnpublishedTokenSet.php in src/
Plugin/ GraphQL/ DataProducer/ AccessUnpublishedTokenSet.php - AddHttpHeaders.php in src/
EventSubscriber/ AddHttpHeaders.php
1 string reference to 'TokenGetter'
1 service uses TokenGetter
File
- src/
TokenGetter.php, line 13
Namespace
Drupal\access_unpublishedView source
class TokenGetter implements EventSubscriberInterface {
/**
* Access unpublished config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* The current token.
*
* @var string
*/
protected $token;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $configFactory) {
$this->config = $configFactory
->get('access_unpublished.settings');
}
/**
* Get the current token.
*
* @return string
* The token.
*/
public function getToken() {
return $this->token;
}
/**
* Set the current token.
*
* @param string $token
* The token.
*/
public function setToken($token) {
$this->token = $token;
}
/**
* Set the token from the current request.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The request event.
*/
public function setTokenFromRequest(GetResponseEvent $event) {
$tokenKey = $this->config
->get('hash_key');
if ($event
->getRequest()->query
->has($tokenKey)) {
$this
->setToken($event
->getRequest()->query
->get($tokenKey));
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'setTokenFromRequest',
50,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TokenGetter:: |
protected | property | Access unpublished config. | |
TokenGetter:: |
protected | property | The current token. | |
TokenGetter:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
TokenGetter:: |
public | function | Get the current token. | |
TokenGetter:: |
public | function | Set the current token. | |
TokenGetter:: |
public | function | Set the token from the current request. | |
TokenGetter:: |
public | function |