You are here

public function VarbaseDashboardUser::build in Varbase Total Control Dashboard 8.5

Same name and namespace in other branches
  1. 8.6 src/Plugin/Block/VarbaseDashboardUser.php \Drupal\varbase_total_control\Plugin\Block\VarbaseDashboardUser::build()
  2. 8 src/Plugin/Block/VarbaseDashboardUser.php \Drupal\varbase_total_control\Plugin\Block\VarbaseDashboardUser::build()
  3. 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 23

Class

VarbaseDashboardUser
Provides a 'Varbase Dashboard User'.

Namespace

Drupal\varbase_total_control\Plugin\Block

Code

public function build() {
  $user = User::load(\Drupal::currentUser()
    ->id());
  $destination = drupal_get_destination();
  $options = [
    $destination,
  ];
  $name = \Drupal::l($user
    ->getUsername(), new Url('entity.user.edit_form', [
    'user' => $user
      ->id(),
    $options,
  ]));
  $url = new Url('entity.user.edit_form', [
    'user' => $user
      ->id(),
    $options,
  ]);
  $body_data = '<div class="content"> <div class="welcome"><p class="welcome-back">' . $this
    ->t('Welcome back') . '</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' => $body_data,
  ];
}