You are here

public function LoginDestinationToolbarLinkBuilder::renderToolbarLinks in Login Destination 8

Same name and namespace in other branches
  1. 8.2 src/LoginDestinationToolbarLinkBuilder.php \Drupal\login_destination\LoginDestinationToolbarLinkBuilder::renderToolbarLinks()

Lazy builder callback for rendering toolbar links.

Return value

array A renderable array as expected by the renderer service.

Overrides ToolbarLinkBuilder::renderToolbarLinks

File

src/LoginDestinationToolbarLinkBuilder.php, line 54

Class

LoginDestinationToolbarLinkBuilder
ToolbarLinkBuilder fills out the placeholders generated in user_toolbar().

Namespace

Drupal\login_destination

Code

public function renderToolbarLinks() {
  $build = $this->innerService
    ->renderToolbarLinks();
  if ($this->account
    ->getAccount()
    ->isAuthenticated()) {
    $url =& $build['#links']['logout']['url'];
    $current = \Drupal::service('path.current')
      ->getPath();

    // Add current param to be able to evaluate previous page.
    $url
      ->setOptions([
      'query' => [
        'current' => $current,
      ],
    ]);
  }
  return $build;
}