‪TYPO3CMS  9.5
TYPO3\CMS\Core\Context\UserAspect Class Reference
Inheritance diagram for TYPO3\CMS\Core\Context\UserAspect:
TYPO3\CMS\Core\Context\AspectInterface

Public Member Functions

 __construct (AbstractUserAuthentication $user=null, array $alternativeGroups=null)
 
int bool string array get (string $name)
 
bool isLoggedIn ()
 
bool isAdmin ()
 
array getGroupIds ()
 
array getGroupNames ()
 
bool isUserOrGroupSet ()
 

Protected Attributes

AbstractUserAuthentication $user
 
int[] $groups
 

Detailed Description

The aspect contains information about a user. Can be used for frontend and backend users.

Allowed properties:

  • ‪id
  • ‪username
  • ‪isLoggedIn
  • ‪groupIds (Array of Ids)
  • ‪groupNames

Definition at line 35 of file UserAspect.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Context\UserAspect::__construct ( AbstractUserAuthentication  $user = null,
array  $alternativeGroups = null 
)
Parameters
AbstractUserAuthentication | null$user
array | null$alternativeGroups

Definition at line 51 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$user.

Member Function Documentation

◆ get()

int bool string array TYPO3\CMS\Core\Context\UserAspect::get ( string  $name)

Fetch common information about the user

Parameters
string$name
Returns
‪int|bool|string|array
Exceptions
AspectPropertyNotFoundException

Implements TYPO3\CMS\Core\Context\AspectInterface.

Definition at line 64 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), TYPO3\CMS\Core\Context\UserAspect\getGroupNames(), TYPO3\CMS\Core\Context\UserAspect\isAdmin(), and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

◆ getGroupIds()

array TYPO3\CMS\Core\Context\UserAspect::getGroupIds ( )

Return the groups the user is a member of

For Frontend Users there are two special groups: "-1" = hide at login "-2" = show at any login

Returns
‪array

Definition at line 120 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$groups, and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

Referenced by TYPO3\CMS\Core\Context\UserAspect\get(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ getGroupNames()

array TYPO3\CMS\Core\Context\UserAspect::getGroupNames ( )

Get the name of all groups, used in Fluid's IfHasRole ViewHelper

Returns
‪array

Definition at line 148 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get().

◆ isAdmin()

bool TYPO3\CMS\Core\Context\UserAspect::isAdmin ( )

Check if admin is set

Returns
‪bool

Definition at line 102 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get().

◆ isLoggedIn()

bool TYPO3\CMS\Core\Context\UserAspect::isLoggedIn ( )

If a frontend user is checked, he/she also needs to have a group, otherwise it is only checked if the frontend user has a uid > 0

Returns
‪bool

Definition at line 89 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\get(), TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ isUserOrGroupSet()

bool TYPO3\CMS\Core\Context\UserAspect::isUserOrGroupSet ( )

Checking if a user is logged in or a group constellation different from "0,-1"

Returns
‪bool TRUE if either a login user is found OR if the group list is set to something else than '0,-1' (could be done even without a user being logged in!)

Definition at line 167 of file UserAspect.php.

References TYPO3\CMS\Core\Context\UserAspect\$groups, TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isLoggedIn().

Member Data Documentation

◆ $groups

int [] TYPO3\CMS\Core\Context\UserAspect::$groups
protected

Alternative list of groups, usually useful for frontend logins with "magic" groups like "-1" and "-2"

Definition at line 45 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\getGroupIds(), and TYPO3\CMS\Core\Context\UserAspect\isUserOrGroupSet().

◆ $user

AbstractUserAuthentication TYPO3\CMS\Core\Context\UserAspect::$user
protected

Definition at line 39 of file UserAspect.php.

Referenced by TYPO3\CMS\Core\Context\UserAspect\__construct().