SfUserAdapter
in package
Wraps $_SESSION data with the sfUser/myUser API.
Reads and writes session data using Symfony's exact key format so that authentication state is shared between Symfony (index.php) and Heratio (heratio.php) during the dual-stack transition period.
Symfony stores session data as flat keys in $_SESSION: 'symfony/user/sfUser/authenticated' => bool 'symfony/user/sfUser/credentials' => array 'symfony/user/sfUser/lastRequest' => int (timestamp) 'symfony/user/sfUser/culture' => string 'symfony/user/sfUser/attributes' => nested array (keyed by namespace)
Table of Contents
Properties
- $user : object|null
Methods
- addCredential() : void
- checkModuleActionAccess() : bool
- Check if the user has access to a module/action.
- getAll() : array<string|int, mixed>
- Get all attributes in a namespace.
- getAttribute() : mixed
- getAttributeHolder() : self
- Get the attribute holder (sfNamespacedParameterHolder compat).
- getCredentials() : array<string|int, mixed>
- getCulture() : string
- getFlash() : mixed
- Get a flash message.
- getGuardUser() : self
- Get the user's myUser/guard instance (for compatibility with AtoM code).
- getLastRequestTime() : int
- Get the last request timestamp.
- getUserID() : int|null
- getUsername() : string|null
- Get the username or email of the current user.
- getUserObject() : object|null
- Get the full user object.
- hasAttribute() : bool
- hasCredential() : bool
- hasFlash() : bool
- Check if a flash message exists.
- hasGroup() : bool
- Check if the user belongs to a group (by group ID).
- isAdministrator() : bool
- isAuthenticated() : bool
- isSuperUser() : bool
- Check if the current user is a super user.
- isTimedOut() : bool
- Check if the session has timed out (default 1800s = 30 min).
- remove() : mixed
- Remove an attribute (alias used by sfNamespacedParameterHolder::remove).
- removeAttribute() : void
- removeCredential() : void
- removeNamespace() : void
- Remove all attributes in a namespace.
- setAttribute() : void
- setAuthenticated() : void
- setCulture() : void
- setFlash() : void
- Set a flash message (displayed on next request).
- signIn() : void
- Sign in a user — replicates myUser::signIn().
- signOut() : void
- Sign out the current user — replicates myUser::signOut().
- updateLastRequest() : void
- Update the last request timestamp.
Properties
$user
public
object|null
$user
= null
Cached user object (loaded by AuthMiddleware)
Methods
addCredential()
public
addCredential(string $credential) : void
Parameters
- $credential : string
checkModuleActionAccess()
Check if the user has access to a module/action.
public
checkModuleActionAccess(string $module, string $action) : bool
In Symfony, this checks security.yml credential requirements. In standalone mode, administrators have access to everything; authenticated users have access unless the module requires a specific credential.
Used by ahgThemeB5Plugin (arStorageService ACL check).
Parameters
- $module : string
- $action : string
Return values
boolgetAll()
Get all attributes in a namespace.
public
getAll([string $ns = 'symfony/user/sfUser/attributes' ]) : array<string|int, mixed>
Parameters
- $ns : string = 'symfony/user/sfUser/attributes'
Return values
array<string|int, mixed>getAttribute()
public
getAttribute(string $name[, mixed $default = null ][, string $ns = 'symfony/user/sfUser/attributes' ]) : mixed
Parameters
- $name : string
- $default : mixed = null
- $ns : string = 'symfony/user/sfUser/attributes'
getAttributeHolder()
Get the attribute holder (sfNamespacedParameterHolder compat).
public
getAttributeHolder() : self
Returns self since this adapter provides the same API.
Return values
selfgetCredentials()
public
getCredentials() : array<string|int, mixed>
Return values
array<string|int, mixed>getCulture()
public
getCulture() : string
Return values
stringgetFlash()
Get a flash message.
public
getFlash(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
getGuardUser()
Get the user's myUser/guard instance (for compatibility with AtoM code).
public
getGuardUser() : self
Returns self since this adapter already provides the user API.
Return values
selfgetLastRequestTime()
Get the last request timestamp.
public
getLastRequestTime() : int
Return values
intgetUserID()
public
getUserID() : int|null
Return values
int|nullgetUsername()
Get the username or email of the current user.
public
getUsername() : string|null
Used by AuditTrail, 3DModel, Search plugins.
Return values
string|nullgetUserObject()
Get the full user object.
public
getUserObject() : object|null
Used by LandingPage plugin.
Return values
object|nullhasAttribute()
public
hasAttribute(string $name[, string $ns = 'symfony/user/sfUser/attributes' ]) : bool
Parameters
- $name : string
- $ns : string = 'symfony/user/sfUser/attributes'
Return values
boolhasCredential()
public
hasCredential(mixed $credential[, bool $useAnd = true ]) : bool
Parameters
- $credential : mixed
- $useAnd : bool = true
Return values
boolhasFlash()
Check if a flash message exists.
public
hasFlash(string $name) : bool
Parameters
- $name : string
Return values
boolhasGroup()
Check if the user belongs to a group (by group ID).
public
hasGroup(int $groupId) : bool
Uses AclService for DB-based lookup (matching myUser behavior).
Parameters
- $groupId : int
Return values
boolisAdministrator()
public
isAdministrator() : bool
Return values
boolisAuthenticated()
public
isAuthenticated() : bool
Return values
boolisSuperUser()
Check if the current user is a super user.
public
isSuperUser() : bool
In AtoM, super user maps to administrator. Used by Reports plugin.
Return values
boolisTimedOut()
Check if the session has timed out (default 1800s = 30 min).
public
isTimedOut([int $timeout = 1800 ]) : bool
Parameters
- $timeout : int = 1800
Return values
boolremove()
Remove an attribute (alias used by sfNamespacedParameterHolder::remove).
public
remove(string $name[, mixed $default = null ][, string $ns = 'symfony/user/sfUser/attributes' ]) : mixed
Parameters
- $name : string
- $default : mixed = null
- $ns : string = 'symfony/user/sfUser/attributes'
removeAttribute()
public
removeAttribute(string $name[, string $ns = 'symfony/user/sfUser/attributes' ]) : void
Parameters
- $name : string
- $ns : string = 'symfony/user/sfUser/attributes'
removeCredential()
public
removeCredential(string $credential) : void
Parameters
- $credential : string
removeNamespace()
Remove all attributes in a namespace.
public
removeNamespace(string $ns) : void
Parameters
- $ns : string
setAttribute()
public
setAttribute(string $name, mixed $value[, string $ns = 'symfony/user/sfUser/attributes' ]) : void
Parameters
- $name : string
- $value : mixed
- $ns : string = 'symfony/user/sfUser/attributes'
setAuthenticated()
public
setAuthenticated(bool $authenticated) : void
Parameters
- $authenticated : bool
setCulture()
public
setCulture(string $culture) : void
Parameters
- $culture : string
setFlash()
Set a flash message (displayed on next request).
public
setFlash(string $name, string $value) : void
Uses Symfony's flash namespace within the attributes array.
Parameters
- $name : string
- $value : string
signIn()
Sign in a user — replicates myUser::signIn().
public
signIn(object $user) : void
Sets session state to match what Symfony's myUser would set.
Parameters
- $user : object
-
User object with id, email/username, slug, name properties
signOut()
Sign out the current user — replicates myUser::signOut().
public
signOut() : void
updateLastRequest()
Update the last request timestamp.
public
updateLastRequest() : void