UserTrackerTab.php in Drupal 10
File
core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
View source
<?php
namespace Drupal\tracker\Plugin\Menu;
use Drupal\Core\Menu\LocalTaskDefault;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class UserTrackerTab extends LocalTaskDefault implements ContainerFactoryPluginInterface {
protected $currentUser;
public function __construct(array $configuration, $plugin_id, array $plugin_definition, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->currentUser = $current_user;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('current_user'));
}
public function getRouteParameters(RouteMatchInterface $route_match) {
return [
'user' => $this->currentUser
->id(),
];
}
}
Classes
Name |
Description |
UserTrackerTab |
Provides route parameters needed to link to the current user tracker tab. |