public function SocialAuthLoginBlock::build in Social Auth 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Block/SocialAuthLoginBlock.php \Drupal\social_auth\Plugin\Block\SocialAuthLoginBlock::build()
- 8 src/Plugin/Block/SocialAuthLoginBlock.php \Drupal\social_auth\Plugin\Block\SocialAuthLoginBlock::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 BlockPluginInterface::build
See also
\Drupal\block\BlockViewBuilder
File
- src/
Plugin/ Block/ SocialAuthLoginBlock.php, line 77
Class
- SocialAuthLoginBlock
- Provides a Social Auth Block for Login.
Namespace
Drupal\social_auth\Plugin\BlockCode
public function build() {
// Add social network name to data passed to template.
// @todo Move `route` and `img_path` settings to the Network declaration.
$networks = $this->networkManager
->getDefinitions();
$social_networks = $this->socialAuthConfig
->get('auth');
foreach ($social_networks as $id => &$social_network) {
$social_network['name'] = NULL;
if (isset($networks[$id]) && isset($networks[$id]['social_network'])) {
$social_network['name'] = $networks[$id]['social_network'];
}
}
return [
'#theme' => 'login_with',
'#social_networks' => $social_networks,
];
}