social_auth_modal-1.x-dev/social_auth_modal.module
social_auth_modal.module
<?php
/**
* @file
* Primary module hooks for Social Auth Modal module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function social_auth_modal_help(string $route_name, RouteMatchInterface $route_match): string {
switch ($route_name) {
// Main module help for the social_auth_modal module.
case 'help.page.social_auth_modal':
$output = '';
$output .= '<h2>' . t('About') . '</h2>';
$output .= '<p>' . t('Social Auth Modal allows users to authenticate with social networks without leaving the current page.') . '</p>';
$output .= '<p>' . t('The authentication page will be opened in a new modal window. After completing the authentication, the modal window will be automatically closed and the current page will be reloaded for applying authenticated session.') . '</p>';
$output .= '<p>' . t('This module is based on <a href=":project_link1">Social Auth</a> and <a href=":project_link2">Social API</a> projects.', [
':project_link1' => 'https://www.drupal.org/project/social_auth',
':project_link2' => 'https://www.drupal.org/project/social_api',
]) . '</p>';
$output .= '<p>' . t('Visit the <a href=":project_link">Project page</a> on Drupal.org for more information.', [
':project_link' => 'https://www.drupal.org/project/social_auth_modal',
]) . '</p>';
return $output;
}
return '';
}
/**
* Implements hook_theme().
*/
function social_auth_modal_theme(): array {
return [
'block__social_auth_login_modal_block' => [
'render element' => 'elements',
'base hook' => 'block',
],
];
}
/**
* Implements hook_preprocess_HOOK() for block templates.
*/
function social_auth_modal_preprocess_block(array &$variables): void {
switch ($variables['base_plugin_id']) {
case 'social_auth_login_modal_block':
$variables['base_path'] = base_path();
// Passing raw data to the template as root level variables.
$variables['social_networks'] = $variables['content']['#social_networks'] ?? [];
$variables['destination'] = $variables['content']['#destination'] ?? '';
break;
}
}
