db0f2b463250fbba0686df58d3e77b4dc0f4ac82
[yaffs-website] / web / core / modules / tracker / src / Plugin / Menu / UserTrackerTab.php
1 <?php
2
3 namespace Drupal\tracker\Plugin\Menu;
4
5 use Drupal\Core\Menu\LocalTaskDefault;
6 use Drupal\Core\Routing\RouteMatchInterface;
7
8 /**
9  * Provides route parameters needed to link to the current user tracker tab.
10  */
11 class UserTrackerTab extends LocalTaskDefault {
12
13   /**
14    * Current user object.
15    *
16    * @var \Drupal\Core\Session\AccountInterface
17    */
18   protected $currentUser;
19
20   /**
21    * Gets the current active user.
22    *
23    * @todo: https://www.drupal.org/node/2105123 put this method in
24    *   \Drupal\Core\Plugin\PluginBase instead.
25    *
26    * @return \Drupal\Core\Session\AccountInterface
27    */
28   protected function currentUser() {
29     if (!$this->currentUser) {
30       $this->currentUser = \Drupal::currentUser();
31     }
32     return $this->currentUser;
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function getRouteParameters(RouteMatchInterface $route_match) {
39     return ['user' => $this->currentUser()->Id()];
40   }
41
42 }