public function FancyLoginBlock::build in Fancy Login 3.0.x
Same name and namespace in other branches
- 8.2 src/Plugin/Block/FancyLoginBlock.php \Drupal\fancy_login\Plugin\Block\FancyLoginBlock::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/ FancyLoginBlock.php, line 63
Class
- FancyLoginBlock
- Provides a 'Fancy Login' block.
Namespace
Drupal\fancy_login\Plugin\BlockCode
public function build() {
if ($this->currentUser
->isAnonymous() || !empty($GLOBALS['menu_admin'])) {
$url = Url::fromRoute('user.login');
return [
'link' => [
'#markup' => Link::fromTextAndUrl($this
->t('Login'), $url)
->toString(),
'#prefix' => '<div id="fancy_login_login_link_wrapper">',
'#suffix' => '</div>',
],
];
}
}