public function getUserFromRoute() {
    $route_match = $this->currentRouteMatch;

    // See if the route has a user parameter and try to retrieve it.
    if (($account = $route_match->getParameter('user'))) {
      if ($account instanceof UserInterface) {
        return $account;
      }
      elseif (is_numeric($account)) {
        $account = $this->userStorage->load($account);

        if ($account instanceof UserInterface) {
          return $account;
        }
      }
    }
  }
public function getUserFromRoute() {
    $route_match = $this->currentRouteMatch;

    // See if the route has a user parameter and try to retrieve it.
    if (($account = $route_match->getParameter('user'))) {
      if ($account instanceof UserInterface) {
        return $account;
      }
      elseif (is_numeric($account)) {
        $account = $this->userStorage->load($account);

        if ($account instanceof UserInterface) {
          return $account;
        }
      }
    }
  }
public function getUserFromRoute ( ) { $ route_match = $ this -> currentRouteMatch ; // See if the route has a user parameter and try to retrieve it. if ( ( $ account = $ route_match -> getParameter ( 'user' ) ) ) { if ( $ account instanceof UserInterface ) { return $ account ; } elseif ( is_numeric ( $ account ) ) { $ account = $ this -> userStorage -> load ( $ account ) ; if ( $ account instanceof UserInterface ) { return $ account ; } } } }
Retrieves the user entity from the current route.

This will try to load the user entity from the route if present.

@return \Drupal\user\UserInterface|null
A user entity if one could be found, NULL otherwise.
Retrieves the user entity from the current route .