class RouteEnhancer in Janrain Registration 8
The route enhancer.
Hierarchy
- class \Drupal\janrain_capture\RouteEnhancer implements EnhancerInterface
Expanded class hierarchy of RouteEnhancer
1 string reference to 'RouteEnhancer'
1 service uses RouteEnhancer
File
- src/
RouteEnhancer.php, line 13
Namespace
Drupal\janrain_captureView source
class RouteEnhancer implements EnhancerInterface {
/**
* The property to set to route's defaults and request's attributes.
*/
public const JANRAIN_ACCOUNT_PROPERTY = '_janrain_account';
/**
* An instance of the "janrain_capture.capture_api" service.
*
* @var \Drupal\janrain_capture\JanrainCaptureApi
*/
protected $captureApi;
/**
* {@inheritdoc}
*/
public function __construct(JanrainCaptureApiInterface $capture_api) {
$this->captureApi = $capture_api;
}
/**
* {@inheritdoc}
*/
public function enhance(array $defaults, Request $request) {
if (isset($defaults['user'])) {
if ($defaults['user'] instanceof UserInterface) {
$janrain_account = $this->captureApi
->isJanrainAccount($defaults['user']);
// The "self" is used since the name of the property
// is closed for modifications.
$defaults[self::JANRAIN_ACCOUNT_PROPERTY] = $janrain_account;
$request->attributes
->set(self::JANRAIN_ACCOUNT_PROPERTY, $janrain_account);
}
}
return $defaults;
}
/**
* {@inheritdoc}
*/
public function applies(Route $route) {
return $route
->getOption('parameters')['user'] ?? FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteEnhancer:: |
protected | property | An instance of the "janrain_capture.capture_api" service. | |
RouteEnhancer:: |
public | function | ||
RouteEnhancer:: |
public | function | ||
RouteEnhancer:: |
public | constant | The property to set to route's defaults and request's attributes. | |
RouteEnhancer:: |
public | function |