public function SocialUserLoginBlock::build in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.2 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.4 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.5 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.6 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.7 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 8.8 modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 10.3.x modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 10.0.x modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 10.1.x modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
- 10.2.x modules/social_features/social_user/src/Plugin/Block/SocialUserLoginBlock.php \Drupal\social_user\Plugin\Block\SocialUserLoginBlock::build()
Builds and returns the renderable array for this block plugin.
If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).
Return value
array A renderable array representing the content of the block.
Overrides UserLoginBlock::build
See also
\Drupal\block\BlockViewBuilder
File
- modules/
social_features/ social_user/ src/ Plugin/ Block/ SocialUserLoginBlock.php, line 21
Class
- SocialUserLoginBlock
- Provides a 'SocialUserLoginBlock' block.
Namespace
Drupal\social_user\Plugin\BlockCode
public function build() {
$form = \Drupal::formBuilder()
->getForm('Drupal\\social_user\\Form\\SocialUserLoginForm');
unset($form['name_or_mail']['#attributes']['autofocus']);
// When unsetting field descriptions, also unset aria-describedby attributes
// to avoid introducing an accessibility bug.
// @todo Do this automatically in https://www.drupal.org/node/2547063.
unset($form['name_or_mail']['#description']);
unset($form['name_or_mail']['#attributes']['aria-describedby']);
unset($form['pass']['#description']);
unset($form['pass']['#attributes']['aria-describedby']);
$form['name_or_mail']['#size'] = 15;
$form['pass']['#size'] = 15;
// See UserLoginBlock::build() for the logic behind this.
$placeholder = 'form_action_p_4r8ITd22yaUvXM6SzwrSe9rnQWe48hz9k1Sxto3pBvE';
$form['#attached']['placeholders'][$placeholder] = [
'#lazy_builder' => [
'\\Drupal\\user\\Plugin\\Block\\UserLoginBlock::renderPlaceholderFormAction',
[],
],
];
$form['#action'] = $placeholder;
// Build action links.
$items = [];
if (\Drupal::config('user.settings')
->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
$items['create_account'] = [
'#type' => 'link',
'#title' => $this
->t('Create new account'),
'#url' => Url::fromRoute('user.register', [], [
'attributes' => [
'title' => $this
->t('Create a new user account.'),
'class' => [
'create-account-link',
],
],
]),
];
}
$items['request_password'] = [
'#type' => 'link',
'#title' => $this
->t('Reset your password'),
'#url' => Url::fromRoute('user.pass', [], [
'attributes' => [
'title' => $this
->t('Send password reset instructions via email.'),
'class' => [
'request-password-link',
],
],
]),
];
return [
'social_user_login_form' => $form,
'user_links' => [
'#theme' => 'item_list',
'#items' => $items,
],
];
}