public function VarbaseDashboardUser::build in Varbase Total Control Dashboard 8.6
Same name and namespace in other branches
- 8 src/Plugin/Block/VarbaseDashboardUser.php \Drupal\varbase_total_control\Plugin\Block\VarbaseDashboardUser::build()
- 8.5 src/Plugin/Block/VarbaseDashboardUser.php \Drupal\varbase_total_control\Plugin\Block\VarbaseDashboardUser::build()
- 9.0.x src/Plugin/Block/VarbaseDashboardUser.php \Drupal\varbase_total_control\Plugin\Block\VarbaseDashboardUser::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/ VarbaseDashboardUser.php, line 106
Class
- VarbaseDashboardUser
- Provides a 'Varbase Dashboard User'.
Namespace
Drupal\varbase_total_control\Plugin\BlockCode
public function build() {
$user = $this->userStorage
->load($this->currentUser
->id());
$destination = $this->redirectDestination
->getAsArray();
$options = [
$destination,
];
$name = Link::fromTextAndUrl($user
->getDisplayName(), new Url('entity.user.edit_form', [
'user' => $user
->id(),
], $options))
->toString();
$url = new Url('entity.user.edit_form', [
'user' => $user
->id(),
$options,
]);
$welcom_back_text = $this
->t('Welcome back');
$markup_data = '<div class="content"> <div class="welcome"><p class="welcome-back">' . $welcom_back_text . '</p><p class="name"> ' . $name . ' </p></div><div class="action-links"><a class="button button-action button--primary button--small" href="' . $url
->toString() . '">' . $this
->t('Edit Account') . '</a></div></div>';
return [
'#type' => 'markup',
'#markup' => $markup_data,
];
}