FOF30\Platform\Joomla\Platform::getUser PHP Method

getUser() public method

Return a user object.
See also: PlatformInterface::getUser()
public getUser ( integer $id = null ) : JUser
$id integer The user ID to load. Skip or use null to retrieve the object for the currently logged in user.
return JUser The JUser object for the specified user
    public function getUser($id = null)
    {
        // If I'm in CLI and I have an ID, let's load the User directly, otherwise JFactory will check the session
        // (which doesn't exists in CLI)
        if ($this->isCli() && $id) {
            return \JUser::getInstance($id);
        }
        return \JFactory::getUser($id);
    }

Usage Example

Example #1
0
 public function getUser($id = null)
 {
     if (isset(static::$user)) {
         return static::$user;
     }
     return parent::getUser($id);
 }