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.
320796
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;
        }
      }
    }
  }
674915
public function getUserAttribute()
    {
        if($this->createdByUserID) {

            // search in cache
            $user = User::where('userID', $this->createdByUserID)->first();

            // search in database
            if (!$user) {
                $user = $this->getRelationValue('user');
            }
            return $user;
        }
        return null;
    }
1096791
public function getCurrentUser() {
    if (empty($this->currentUser)) {
      $this->currentUser = \Drupal::service('current_user');
    }
    return $this->currentUser;
  }
145321
protected function getUser()
    {
        if ($this->_user === null) {
            $user = $this->module->model('UserIdentity');
            $this->_user = $user::findByUsername($this->username);
        }
        return $this->_user;
    }
657353
public function getRoute() {
		return $this->route ? $this->route : ($this->request ? $this->request->getRoute() : null);
// 		return $this->request->getRoute();
	}
1171785
public function get()
    {
        $customer = null;
        $user = null;

        if (true === $this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            // user is authenticated
            $user = $this->securityContext->getToken()->getUser();

            if (!$user instanceof UserInterface) {
                throw new \RuntimeException('User must be an instance of Symfony\Component\Security\Core\User\UserInterface');
            }

            $customer = $this->customerManager->findOneBy([
                'user' => $user->getId(),
            ]);
        }

        if (!$customer) {
            $basket = $this->getBasket();

            if ($basket && $basket->getCustomer()) {
                $customer = $basket->getCustomer();
            }
        }

        if (!$customer) {
            $customer = $this->customerManager->create();
        }

        if (!$customer->getLocale()) {
            $customer->setLocale($this->locale);
        }

        if ($user && $customer) {
            $customer->setUser($user);
        }

        return $customer;
    }
38907
function LoadCurrent()
    {
        $this->user = null;
        $userID = null;
        if (isset($_SESSION[self::$sessionParam]))
             $userID = $_SESSION[self::$sessionParam];
        
        if ($userID)
        {
            $user = new User($userID);
            if ($user->Exists())
                $this->user = $user;
        }
        return $this->user !== null;
    }
526881
public function getUser($user)
    {
        $result = null;
        if ($user === 'current') {
            $u = new \User();
            if ($u->isRegistered()) {
                $result = $u;
            }
        } elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
            $result = \User::getByUserID($user);
        } elseif ($user instanceof UserService) {
            $result = $user;
        } elseif ($user instanceof UserEntity) {
            $result = \User::getByUserID($user->getUserID());
        }

        return $result;
    }
867649
public function user()
	{
		if ($this->loggedOut) return;

		// If we have already retrieved the user for the current request we can just
		// return it back immediately. We do not want to pull the user data every
		// request into the method because that would tremendously slow an app.
		if ( ! is_null($this->user))
		{
			return $this->user;
		}

		$id = $this->session->get($this->getName());

		// First we will try to load the user using the identifier in the session if
		// one exists. Otherwise we will check for a "remember me" cookie in this
		// request, and if one exists, attempt to retrieve the user using that.
		$user = null;

		if ( ! is_null($id))
		{
			$user = $this->provider->retrieveById($id);
		}

		// If the user is null, but we decrypt a "recaller" cookie we can attempt to
		// pull the user data on that cookie which serves as a remember cookie on
		// the application. Once we have a user we can return it to the caller.
		$recaller = $this->getRecaller();

		if (is_null($user) && ! is_null($recaller))
		{
			$user = $this->getUserByRecaller($recaller);

			if ($user)
			{
				$this->updateSession($user->getAuthIdentifier());

				$this->fireLoginEvent($user, true);
			}
		}

		return $this->user = $user;
	}
248866
public static function getCurrentUser()
    {
        if (static::$currentUser instanceof AVUser)
        {
            return static::$currentUser;
        }
        $storage = AVClient::getStorage();
        $userData = $storage->get("user");
        if ($userData instanceof AVUser)
        {
            static::$currentUser = $userData;

            return $userData;
        }
        if (isset($userData["id"]) && isset($userData["_sessionToken"]))
        {
            $user = AVUser::create("_User", $userData["id"]);
            unset($userData["id"]);
            $user->_sessionToken = $userData["_sessionToken"];
            unset($userData["_sessionToken"]);
            foreach ($userData as $key => $value)
            {
                $user->set($key, $value);
            }
            $user->_opSetQueue = array();
            static::$currentUser = $user;

            return $user;
        }

        return null;
    }
1045355
public function getUser() {
    if ($this->user !== null) {
      // we've already determined this and cached the value.
      return $this->user;
    }

    return $this->user = $this->getUserFromAvailableData();
  }
588089
public function getUser()
    {
        if ($this->_user === null) {
            /* @var $user User */
            $this->_user = is_string($this->userComponent) ? Yii::$app->get($this->userComponent,
                false) : $this->userComponent;
        }
        return $this->_user;
    }
991320
public function user()
    {
        if ($this->loggedOut) {
            return NULL;
        }
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (!is_null($this->user)) {
            if ($this->session->get('expires_at') < Carbon::now()) {
                $this->logout();

                return NULL;
            }

            return $this->user;
        }
        // First we will try to load the user using the identifier in the session if
        // one exists. Otherwise we will check for a "remember me" cookie in this
        // request, and if one exists, attempt to retrieve the user using that.
        $id = $this->session->get($this->getName());
        $user = NULL;
        if (!is_null($id)) {
            $token = $this->validateToken($id);
            if (!$token) {
                return NULL;
            }
            $user = new User();
            if ($token->hasClaim('sub')) {
                $user->id = $token->getClaim('sub');
            }
            if ($token->hasClaim('name')) {
                $user->name = $token->getClaim('name');
            }
            if ($token->hasClaim('email')) {
                $user->email = $token->getClaim('email');
            }
            if ($token->hasClaim('roles')) {
                $user->roles = explode(' ', $token->getClaim('roles'));
            }
            if ($token->hasClaim('registries')) {
                $user->registries = explode(' ', $token->getClaim('registries'));
            }
            if ($token->hasClaim('cpf')) {
                $user->cpf = $token->getClaim('cpf');
            }
            if ($token->hasClaim('avatar')) {
                $user->avatar = $token->getClaim('avatar');
            }
            if ($user) {
                $this->fireAuthenticatedEvent($user);
            }
        }

        return $this->user = $user;
    }
452850
public function getUser($userId)
    {
        // Check if we've already retrieved this user.
        if (isset($this->userEntities[$userId])) {
            return $this->userEntities[$userId];
        }

        $query = $this->getUserQuery($userId);
        /** @var Entity\Users $userEntity */
        if ($userEntity = $this->findOneWith($query)) {
            $this->unsetSensitiveFields($userEntity);
        }

        // Remember the user
        $this->userEntities[$userId] = $userEntity;

        return $userEntity;
    }
1044679
public static function getGeneral()
	{
		$user = new User();
		$entity = self::createGeneral();
		$user->setEntity($entity);
		return $user;
	}
886724
private function getCurrentUser($required)
    {
        $result = null;
        $id = $this->getCurrentUserID($required);
        if ($id !== null) {
            $result = $this->getEntityManager()->find(UserEntity::class, $id);
        }

        if ($result === null && $required) {
            throw new UserMessageException(t('No logged in user'));
        }

        return $result;
    }
642790
public function get()
    {
        $uri = null;
        if ($this->context) {
            $uri = $this->context->getBaseUri() . '/';
        }
        $uri .= $this->params['endpoint'];
        
        $uri .= sprintf("?page=%d&perpage=%d"
            , $this->page
            , $this->perpage
            );
        
        // add filter if value is not empty
        foreach ($this->filters as $filter) {
            if (! empty($filter['value'])) {
                $uri .= sprintf("&%s=%s"
                    , $filter['field']
                    , rawurlencode($filter['value'])
                    );
            }
        }
        
        $res = $this->client->call($uri);

        // get and preserve pagination
        $lr = Client::getLastResponse();
        $this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : [];
        
        // convert array to Entities collection
        $this->data = [];
        foreach ($res as $data) {
            $this->data[] = (new Entity([], $this->client))->setData($data);
        }
        $this->current = 0;
        
        return $this->data;
    }