class LoginDestinationToolbarLinkBuilder in Login Destination 8.2
Same name and namespace in other branches
- 8 src/LoginDestinationToolbarLinkBuilder.php \Drupal\login_destination\LoginDestinationToolbarLinkBuilder
ToolbarLinkBuilder fills out the placeholders generated in user_toolbar().
Hierarchy
- class \Drupal\user\ToolbarLinkBuilder implements TrustedCallbackInterface uses StringTranslationTrait
- class \Drupal\login_destination\LoginDestinationToolbarLinkBuilder
Expanded class hierarchy of LoginDestinationToolbarLinkBuilder
1 string reference to 'LoginDestinationToolbarLinkBuilder'
1 service uses LoginDestinationToolbarLinkBuilder
File
- src/
LoginDestinationToolbarLinkBuilder.php, line 12
Namespace
Drupal\login_destinationView source
class LoginDestinationToolbarLinkBuilder extends ToolbarLinkBuilder {
/**
* The decorated service.
*
* @var \Drupal\user\ToolbarLinkBuilder
*/
protected $innerService;
/**
* The current path service.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* ToolbarHandler constructor.
*
* @param \Drupal\user\ToolbarLinkBuilder $inner_service
* The decorated service.
* @param \Drupal\Core\Path\CurrentPathStack $current_path
* The current path.
* @param \Drupal\Core\Session\AccountProxyInterface $account
* The current user.
*/
public function __construct(ToolbarLinkBuilder $inner_service, CurrentPathStack $current_path, AccountProxyInterface $account) {
$this->innerService = $inner_service;
$this->currentPath = $current_path;
parent::__construct($account);
}
/**
* Pass any undefined method calls onto the inner service.
*
* @param string $method
* The method being called.
* @param array $args
* The arguments passed to the method.
*
* @return mixed
* The inner services response.
*/
public function __call($method, array $args = []) {
return call_user_func_array([
$this->innerService,
$method,
], $args);
}
/**
* Lazy builder callback for rendering toolbar links.
*
* @return array
* A renderable array as expected by the renderer service.
*/
public function renderToolbarLinks() {
$build = $this->innerService
->renderToolbarLinks();
if ($this->account
->getAccount()
->isAuthenticated()) {
$url =& $build['#links']['logout']['url'];
$current = $this->currentPath
->getPath();
// Add current param to be able to evaluate previous page.
$url
->setOptions([
'query' => [
'current' => $current,
],
]);
}
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoginDestinationToolbarLinkBuilder:: |
protected | property | The current path service. | |
LoginDestinationToolbarLinkBuilder:: |
protected | property | The decorated service. | |
LoginDestinationToolbarLinkBuilder:: |
public | function |
Lazy builder callback for rendering toolbar links. Overrides ToolbarLinkBuilder:: |
|
LoginDestinationToolbarLinkBuilder:: |
public | function | Pass any undefined method calls onto the inner service. | |
LoginDestinationToolbarLinkBuilder:: |
public | function |
ToolbarHandler constructor. Overrides ToolbarLinkBuilder:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ToolbarLinkBuilder:: |
protected | property | The current user. | |
ToolbarLinkBuilder:: |
public | function | Lazy builder callback for rendering the username. | |
ToolbarLinkBuilder:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |