Mercurial > hg > isophonics-drupal-site
annotate core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\tracker\Plugin\Menu; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Menu\LocalTaskDefault; |
Chris@0 | 6 use Drupal\Core\Routing\RouteMatchInterface; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Provides route parameters needed to link to the current user tracker tab. |
Chris@0 | 10 */ |
Chris@0 | 11 class UserTrackerTab extends LocalTaskDefault { |
Chris@0 | 12 |
Chris@0 | 13 /** |
Chris@0 | 14 * Current user object. |
Chris@0 | 15 * |
Chris@0 | 16 * @var \Drupal\Core\Session\AccountInterface |
Chris@0 | 17 */ |
Chris@0 | 18 protected $currentUser; |
Chris@0 | 19 |
Chris@0 | 20 /** |
Chris@0 | 21 * Gets the current active user. |
Chris@0 | 22 * |
Chris@0 | 23 * @todo: https://www.drupal.org/node/2105123 put this method in |
Chris@0 | 24 * \Drupal\Core\Plugin\PluginBase instead. |
Chris@0 | 25 * |
Chris@0 | 26 * @return \Drupal\Core\Session\AccountInterface |
Chris@0 | 27 */ |
Chris@0 | 28 protected function currentUser() { |
Chris@0 | 29 if (!$this->currentUser) { |
Chris@0 | 30 $this->currentUser = \Drupal::currentUser(); |
Chris@0 | 31 } |
Chris@0 | 32 return $this->currentUser; |
Chris@0 | 33 } |
Chris@0 | 34 |
Chris@0 | 35 /** |
Chris@0 | 36 * {@inheritdoc} |
Chris@0 | 37 */ |
Chris@0 | 38 public function getRouteParameters(RouteMatchInterface $route_match) { |
Chris@0 | 39 return ['user' => $this->currentUser()->Id()]; |
Chris@0 | 40 } |
Chris@0 | 41 |
Chris@0 | 42 } |