You are here

public function RouteEnhancer::enhance in Janrain Registration 8

File

src/RouteEnhancer.php, line 37

Class

RouteEnhancer
The route enhancer.

Namespace

Drupal\janrain_capture

Code

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;
}