UserService
extends AbstractDbService
in package
implements
DbTableAwareInterface, LoggerAwareInterface, UserServiceInterface, UserSessionPersistenceInterface
Uses
DbTableAwareTrait, LoggerAwareTrait
Database service for user.
Tags
Interfaces, Classes, Traits and Enums
- DbTableAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Table\PluginManager
- LoggerAwareInterface
- UserServiceInterface
- Database service interface for users.
- UserSessionPersistenceInterface
- Interface for persisting user data in the session.
Table of Contents
- $tableManager : PluginManager
- Database table plugin manager
- $userSessionContainer : Container
- __construct() : mixed
- Constructor
- addUserDataToSession() : void
- Update session container to store data representing a user (used by privacy mode).
- addUserIdToSession() : void
- Update session container to store user ID (used outside of privacy mode).
- clearUserFromSession() : void
- Clear the user data from the session.
- createEntity() : UserEntityInterface
- Create a new user entity.
- createEntityForUsername() : UserEntityInterface
- Create an entity for the specified username.
- deleteUser() : void
- Delete a user entity.
- getAllUsersWithCatUsernames() : array<string|int, UserEntityInterface>
- Get all rows with catalog usernames.
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getInsecureRows() : array<string|int, UserEntityInterface>
- Get user rows with insecure catalog passwords.
- getUserByCatId() : UserEntityInterface|null
- Retrieve a user object by catalog ID. Returns null if no match is found.
- getUserByEmail() : UserEntityInterface|null
- Retrieve a user object by email address. Returns null if no match is found.
- getUserByField() : UserEntityInterface|null
- Retrieve a user object from the database based on the given field.
- getUserById() : UserEntityInterface|null
- Retrieve a user object from the database based on ID.
- getUserByUsername() : UserEntityInterface|null
- Retrieve a user object by username. Returns null if no match is found.
- getUserByVerifyHash() : UserEntityInterface|null
- Retrieve a user object by verify hash. Returns null if no match is found.
- getUserFromSession() : UserEntityInterface|null
- Build a user entity using data from a session container. Return null if user data cannot be found.
- hasUserSessionData() : bool
- Is there user data currently stored in the session container?
- persistEntity() : void
- Persist an entity.
- setDbTableManager() : void
- Set the table plugin manager.
- updateUserEmail() : void
- Update the user's email address, if appropriate. Note that this does NOT automatically save the row; it assumes a subsequent call will be made to persist the data.
- debug() : void
- Log a debug message.
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
Properties
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
$userSessionContainer
protected
Container
$userSessionContainer
Methods
__construct()
Constructor
public
__construct(Container $userSessionContainer) : mixed
Parameters
- $userSessionContainer : Container
-
Session container for user data
Return values
mixed —addUserDataToSession()
Update session container to store data representing a user (used by privacy mode).
public
addUserDataToSession(UserEntityInterface $user) : void
Parameters
- $user : UserEntityInterface
-
User to store in session.
Tags
Return values
void —addUserIdToSession()
Update session container to store user ID (used outside of privacy mode).
public
addUserIdToSession(int $id) : void
Parameters
- $id : int
-
User ID
Return values
void —clearUserFromSession()
Clear the user data from the session.
public
clearUserFromSession() : void
Return values
void —createEntity()
Create a new user entity.
public
createEntity() : UserEntityInterface
Return values
UserEntityInterface —createEntityForUsername()
Create an entity for the specified username.
public
createEntityForUsername(string $username) : UserEntityInterface
Parameters
- $username : string
-
Username
Return values
UserEntityInterface —deleteUser()
Delete a user entity.
public
deleteUser(UserEntityInterface|int $userOrId) : void
Parameters
- $userOrId : UserEntityInterface|int
-
User entity object or ID to delete
Return values
void —getAllUsersWithCatUsernames()
Get all rows with catalog usernames.
public
getAllUsersWithCatUsernames() : array<string|int, UserEntityInterface>
Return values
array<string|int, UserEntityInterface> —getDbTable()
Get a database table object.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table to load.
Return values
Gateway —getDbTableManager()
Get the table plugin manager. Throw an exception if it is missing.
public
getDbTableManager() : PluginManager
Tags
Return values
PluginManager —getInsecureRows()
Get user rows with insecure catalog passwords.
public
getInsecureRows() : array<string|int, UserEntityInterface>
Return values
array<string|int, UserEntityInterface> —getUserByCatId()
Retrieve a user object by catalog ID. Returns null if no match is found.
public
getUserByCatId(string $catId) : UserEntityInterface|null
Parameters
- $catId : string
-
Catalog ID
Return values
UserEntityInterface|null —getUserByEmail()
Retrieve a user object by email address. Returns null if no match is found.
public
getUserByEmail(string $email) : UserEntityInterface|null
Parameters
- $email : string
-
Email address
Return values
UserEntityInterface|null —getUserByField()
Retrieve a user object from the database based on the given field.
public
getUserByField(string $fieldName, int|string|null $fieldValue) : UserEntityInterface|null
Field name must be id, username, email, verify_hash or cat_id.
Parameters
- $fieldName : string
-
Field name
- $fieldValue : int|string|null
-
Field value
Return values
UserEntityInterface|null —getUserById()
Retrieve a user object from the database based on ID.
public
getUserById(int $id) : UserEntityInterface|null
Parameters
- $id : int
-
ID.
Return values
UserEntityInterface|null —getUserByUsername()
Retrieve a user object by username. Returns null if no match is found.
public
getUserByUsername(string $username) : UserEntityInterface|null
Parameters
- $username : string
-
Username
Return values
UserEntityInterface|null —getUserByVerifyHash()
Retrieve a user object by verify hash. Returns null if no match is found.
public
getUserByVerifyHash(string $hash) : UserEntityInterface|null
Parameters
- $hash : string
-
Verify hash
Return values
UserEntityInterface|null —getUserFromSession()
Build a user entity using data from a session container. Return null if user data cannot be found.
public
getUserFromSession() : UserEntityInterface|null
Return values
UserEntityInterface|null —hasUserSessionData()
Is there user data currently stored in the session container?
public
hasUserSessionData() : bool
Return values
bool —persistEntity()
Persist an entity.
public
persistEntity(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Entity to persist.
Return values
void —setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —updateUserEmail()
Update the user's email address, if appropriate. Note that this does NOT automatically save the row; it assumes a subsequent call will be made to persist the data.
public
updateUserEmail(UserEntityInterface $user, string $email[, bool $userProvided = false ]) : void
Parameters
- $user : UserEntityInterface
-
User entity to update
- $email : string
-
New email address
- $userProvided : bool = false
-
Was this email provided by the user (true) or an automated lookup (false)?
Return values
void —debug()
Log a debug message.
protected
debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —log()
Send a message to the logger.
protected
log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
- $level : string
-
Log level
- $message : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = false
-
Prepend class name to message?
Return values
void —logError()
Log an error message.
protected
logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —logWarning()
Log a warning message.
protected
logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?