UserTrackerTab.php

Same filename and directory in other branches
  1. 9 core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
  2. 10 core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
  3. 11.x core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php

Namespace

Drupal\tracker\Plugin\Menu

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\Routing\RouteMatchInterface;

/**
 * Provides route parameters needed to link to the current user tracker tab.
 */
class UserTrackerTab extends LocalTaskDefault {
    
    /**
     * Current user object.
     *
     * @var \Drupal\Core\Session\AccountInterface
     */
    protected $currentUser;
    
    /**
     * Gets the current active user.
     *
     * @todo: https://www.drupal.org/node/2105123 put this method in
     *   \Drupal\Core\Plugin\PluginBase instead.
     *
     * @return \Drupal\Core\Session\AccountInterface
     */
    protected function currentUser() {
        if (!$this->currentUser) {
            $this->currentUser = \Drupal::currentUser();
        }
        return $this->currentUser;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getRouteParameters(RouteMatchInterface $route_match) {
        return [
            'user' => $this->currentUser()
                ->Id(),
        ];
    }

}

Classes

Title Deprecated Summary
UserTrackerTab Provides route parameters needed to link to the current user tracker tab.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.