janrain_capture.module in Janrain Registration 8
Same filename and directory in other branches
Janrain Capture.
File
janrain_capture.moduleView source
<?php
/**
* @file
* Janrain Capture.
*/
use Drupal\user\UserInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_cron().
*
* @internal
*/
function janrain_capture_cron() : void {
/* @var \Drupal\janrain_capture\ScreenLoaderManager $screen_loader_manager */
$screen_loader_manager = \Drupal::service('janrain_capture.screen_loader_manager');
if ($screen_loader_manager
->isRemote()) {
$screen_loader_manager
->updateRemoteScreens();
}
}
/**
* Implements hook_page_attachments().
*
* @internal
*/
function janrain_capture_page_attachments(array &$attachments) : void {
if (!isset($attachments['#attached'])) {
$attachments['#attached'] = [];
}
$attachments['#attached'] = array_merge_recursive($attachments['#attached'], \Drupal::service('janrain_capture.markup_builder')
->getPageAttachment());
}
/**
* Implements hook_page_bottom().
*
* @internal
*/
function janrain_capture_page_top(array &$page_top) : void {
$page_top += \Drupal::service('janrain_capture.markup_builder')
->getScreenRenderArray('signin');
}
/**
* Implements hook_ENTITY_TYPE_view().
*
* @internal
*/
function janrain_capture_user_view(array &$build, UserInterface $user) : void {
if (\Drupal::service('janrain_capture.capture_api')
->isJanrainAccount($user)) {
$build += \Drupal::service('janrain_capture.markup_builder')
->getScreenRenderArray('public-profile');
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function janrain_capture_form_user_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$api = \Drupal::service('janrain_capture.capture_api');
$account = $form_state
->getFormObject()
->getEntity();
if ($api
->isJanrainAccount($account)) {
// Check to make sure the user accounts match.
if (\Drupal::currentUser()
->id() === $account
->id()) {
$form['account']['#access'] = FALSE;
$form = [
'#id' => 'janrain_capture_edit_profile_form',
'account' => $form['account'],
'janrain_capture_edit_js' => [
'#markup' => '<script>var access_token = "' . $api
->getAccessToken() . '";</script>',
'#allowed_tags' => [
'script',
],
],
'janrain_capture_edit_profile' => \Drupal::service('janrain_capture.markup_builder')
->getScreenRenderArray('edit-profile'),
];
}
}
}
Functions
Name | Description |
---|---|
janrain_capture_cron | Implements hook_cron(). |
janrain_capture_form_user_form_alter | Implements hook_form_FORM_ID_alter(). |
janrain_capture_page_attachments | Implements hook_page_attachments(). |
janrain_capture_page_top | Implements hook_page_bottom(). |
janrain_capture_user_view | Implements hook_ENTITY_TYPE_view(). |