AbstractUser
extends PermanentEntity
in package
The abstract user class
The user class represents a user known by the current website as a permanent entity. This class is commonly inherited by a user class for registered users. But a user can be a Facebook user or a Site user for example.
Require core plugin
Table of Contents
Constants
- IS_LOGGED = 1
- LOGGED_FORCED = 3
- NOT_LOGGED = 0
- OUTPUT_MODEL_ALL = 'all'
- OUTPUT_MODEL_MINIMALS = 'min'
- OUTPUT_MODEL_PUBLIC = 'public'
Properties
- $checkFieldIntegrity : bool
- Should check fields integrity when load one element ?
- $data : array<string|int, mixed>
- The object's data
- $entityMetadata : array<string|int, mixed>
- $instanceName : string|null
- The instance to use, see config file, if null, use default
- $isDeleted : bool
- Is this object deleted ?
- $knownEntities : array<string|int, mixed>
- Known entities (but may be not loaded & initialized)
- $loggedUser : self|null
- $mappingEntityClass : array<string|int, mixed>
- Entity classes
- $onSavedInProgress : bool
- Is this object called onSaved ? It prevents recursive calls
- $originalData : array<string|int, mixed>
- The original data of object Only filled when edited to store previous data (first loaded, got from db)
- $userClass : string|null
Methods
- __construct() : mixed
- __destruct() : mixed
- Destructor
- __get() : mixed
- Magic getter
- __isset() : bool
- Magic isset
- __set() : mixed
- Magic setter for entity's property
- __toString() : string
- Magic string conversion
- _text() : void
- Translate text according to the object domain
- asArray() : array<string|int, mixed>
- buildRaw() : static
- cacheInstances() : array<string|int, mixed>
- Cache an array of objects
- canAlter() : bool
- Check if this user can alter data on the given user
- canDo() : bool
- Check if this user can affect data on the given user
- checkIntegrity() : mixed
- Check object integrity & validity
- checkPerm() : bool
- Check permissions
- checkUserInput() : array<string|int, mixed>
- Check if the class could generate a valid object from $input.
- create() : int
- Create a new permanent object from ths input data.
- createAndGet() : static
- Create a new permanent object
- ei() : string
- Escape identifier through instance
- equals() : bool
- Verify equality with another object
- escapeIdentifier() : string
- Escape identifier through instance
- fillLogEvent() : void
- Add an $event log in this $array
- findEntityObject() : PermanentEntity
- Get entity instance by type and id
- formatValue() : string
- Escape value through instance
- free() : bool
- Free the object (remove)
- get() : SqlSelectRequest|array<string|int, mixed>|PermanentEntity|null
- Get some permanent objects Get an objects' list using this class' table.
- getActiveUser() : AbstractUser|null
- Get active user
- getAppRoles() : array<string|int, mixed>
- Get application roles
- getAuthenticationToken() : string
- getByAuthenticationToken() : static|null
- getCachedInstance() : static|null
- getClass() : string
- Get the name of this class
- getCreateOperation() : CreateTransactionOperation
- Get the create operation
- getDeleteOperation() : DeleteTransactionOperation
- Get the delete operation for this object
- getDescriptor() : EntityDescriptor
- getDomain() : string
- Get the domain of this class, can be guessed from $table or specified in $domain.
- getEntity() : string
- Get this entity name
- getEntityWhereClause() : string
- Helper method to get whereClause string from an entity
- getField() : FieldDescriptor
- Get field descriptor from field name
- getFields() : array<string|int, string>
- Get the available fields of this entity
- getIdField() : string
- Get the ID field name of this entity
- getLabel() : string
- getLogEvent() : array<string|int, mixed>
- Build a new log event for $event for this time and the user IP address.
- getLoggedUserId() : string
- Get ID if user is logged
- getMetadata() : EntityMetadata|null
- getReference() : string
- getRoleAccessLevel() : int
- Get access level of a role
- getSqlAdapter() : AbstractSqlAdapter
- Get the SQL Adapter of this class
- getTable() : string
- Get the table of this class
- getUpdateOperation() : UpdateTransactionOperation
- Get the update operation
- getUserAccess() : int
- Get user access If anonymous, the user access is -1 (below zero)
- getUserByLogin() : mixed
- getUserClass() : string|null
- getUserRoles() : array<string|int, mixed>
- Get all user roles
- getValue() : mixed
- Get the value of field $key or all data values if $key is null.
- hasChanges() : bool
- hasRoleAccessLevel() : bool
- Check user can use the role's permission
- id() : string
- Get this permanent object's ID
- initialize() : void
- Initialize entity class You must call this method after the class declaration
- initializeWithDescriptor() : void
- isAdmin() : bool
- isDeleted() : bool
- Check if this object is deleted
- isUserAdmin() : bool
- Checks if this user has admin access level.
- isValid() : bool
- Check if this object is valid
- listKnownEntities() : array<string|int, string>
- List all known entities
- listLoginFields() : array<string|int, string>
- List all available login fields
- load() : PermanentEntity|null
- Loads the object with the ID $id or the array data.
- loadEntity() : PermanentEntity|null
- Try to load entity from an entity string and an id integer
- logEvent() : void
- Log an event
- loggedCanAccessToRoute() : bool
- Check if this user can access to a module
- loggedCanDo() : bool
- Check if this user can do a restricted action
- loggedHasDeveloperAccess() : bool
- Check if this user has developer access
- markAsDeleted() : static
- Mark this object as deleted
- object() : static|int|null
- Get the object whatever we give to it
- onAuthenticated() : mixed
- Callback when user is authenticated
- onEdit() : void
- onSaved() : void
- Callback when object was saved
- onValidCreate() : bool
- Callback when validating create
- onValidEdit() : bool
- Callback when validating create
- onValidUpdate() : bool
- Callback when validating update
- putValue() : void
- Validate field value and set it
- registerEntity() : void
- Register an entity
- reload() : bool
- Reload fields from database Also it removes the reloaded fields from the modified ones list.
- remove() : bool
- What do you think it does ?
- reportException() : void
- Report an UserException
- requestInsert() : SqlInsertRequest
- Get insert query
- requestSelect() : SqlSelectRequest
- Get select query
- requestUpdate() : SqlUpdateRequest
- Get update query
- requireAuthenticatedUserId() : int
- revert() : PermanentEntity
- save() : bool|int
- Save current changes of this entity to the database Input is NOT validated here, we recommend it for programming changes only
- setCheckFieldIntegrity() : void
- Serve to bypass the integrity check, should be only used while developing
- setUserClass() : mixed
- setValue() : $this
- Set the field $key with the new $value.
- testUserInput() : bool
- Test user input
- text() : string
- Translate text according to the object domain
- throwException() : void
- Throws an UserException with the current domain
- throwNotFound() : mixed
- Throws an NotFoundException with the current domain
- uid() : string
- Get this permanent object's unique ID
- update() : bool
- Update this permanent entity from input data array Parameter $fields is really useful to allow partial modification only (against form hack).
- validateValue() : void
- Validate field value from the validator using this entity
- verifyConflicts() : void
- Check for object
- checkCache() : static
- Check if this object is cached and cache it
- formatFieldSqlValue() : mixed
- Format the value from PHP type to SQL scalar
- getExportData() : array<string|int, mixed>
- Get data with an exportable format.
- instantiate() : static
- Instantiate object from data, allowing you to instantiate child class
- parseFieldSqlValue() : mixed
- Parse the value from SQL scalar to PHP type
- setCachedInstance() : void
- setData() : void
- Set all data of object (internal use only)
Constants
IS_LOGGED
public
mixed
IS_LOGGED
= 1
LOGGED_FORCED
public
mixed
LOGGED_FORCED
= 3
NOT_LOGGED
public
mixed
NOT_LOGGED
= 0
OUTPUT_MODEL_ALL
public
mixed
OUTPUT_MODEL_ALL
= 'all'
OUTPUT_MODEL_MINIMALS
public
mixed
OUTPUT_MODEL_MINIMALS
= 'min'
OUTPUT_MODEL_PUBLIC
public
mixed
OUTPUT_MODEL_PUBLIC
= 'public'
Properties
$checkFieldIntegrity
Should check fields integrity when load one element ?
protected
static bool
$checkFieldIntegrity
= !!ENTITY_CLASS_CHECK
$data
The object's data
protected
array<string|int, mixed>
$data
= []
$entityMetadata
protected
static array<string|int, mixed>
$entityMetadata
= []
Array with metadata of all entities mapped by class name
$instanceName
The instance to use, see config file, if null, use default
protected
static string|null
$instanceName
= null
Tags
$isDeleted
Is this object deleted ?
protected
bool
$isDeleted
= false
$knownEntities
Known entities (but may be not loaded & initialized)
protected
static array<string|int, mixed>
$knownEntities
= []
$loggedUser
protected
static self|null
$loggedUser
= null
$mappingEntityClass
Entity classes
protected
static array<string|int, mixed>
$mappingEntityClass
= []
$onSavedInProgress
Is this object called onSaved ? It prevents recursive calls
protected
bool
$onSavedInProgress
= false
$originalData
The original data of object Only filled when edited to store previous data (first loaded, got from db)
protected
array<string|int, mixed>
$originalData
= []
$userClass
protected
static string|null
$userClass
= null
Methods
__construct()
public
__construct(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
__destruct()
Destructor
public
__destruct() : mixed
If something was modified, it saves the new data.
__get()
Magic getter
public
__get(string $name) : mixed
Parameters
- $name : string
-
Name of the property to get
Return values
mixed —The value of field $name
Get the value of field $name. 'all' returns all fields.
__isset()
Magic isset
public
__isset(string $name) : bool
Parameters
- $name : string
-
Name of the property to check is set
Return values
bool —Checks if the field $name is set.
__set()
Magic setter for entity's property
public
__set(string $name, mixed $value) : mixed
Parameters
- $name : string
-
Name of the property to set
- $value : mixed
-
New value of the property
Tags
__toString()
Magic string conversion
public
__toString() : string
Return values
string —The string value of this object
The string value is the contents of the publication.
_text()
Translate text according to the object domain
public
static _text(string $text[, array<string|int, mixed> $values = [] ]) : void
Parameters
- $text : string
-
The text to translate
- $values : array<string|int, mixed> = []
-
The values array to replace in text. Could be used as second parameter.
Tags
asArray()
public
asArray([string $model = self::OUTPUT_MODEL_ALL ]) : array<string|int, mixed>
Parameters
- $model : string = self::OUTPUT_MODEL_ALL
Return values
array<string|int, mixed>buildRaw()
public
static buildRaw(array<string|int, mixed> $data[, bool $useCache = true ]) : static
Parameters
- $data : array<string|int, mixed>
- $useCache : bool = true
Return values
staticcacheInstances()
Cache an array of objects
public
static cacheInstances(array<string|int, static> &$instances) : array<string|int, mixed>
Parameters
- $instances : array<string|int, static>
Return values
array<string|int, mixed>canAlter()
Check if this user can alter data on the given user
public
canAlter(AbstractUser $user) : bool
Parameters
- $user : AbstractUser
-
The user we want to edit
Tags
Return values
bool —True if this user has enough acess level to edit $user or he is altering himself
canDo()
Check if this user can affect data on the given user
public
canDo(string $action[, object $object = null ]) : bool
Parameters
- $action : string
-
The action to look for
- $object : object = null
-
The object we want to edit
Tags
Return values
bool —True if this user has enough access level to alter $object (or he is altering himself)
checkIntegrity()
Check object integrity & validity
public
checkIntegrity() : mixed
checkPerm()
Check permissions
public
checkPerm(int|string $right) : bool
Parameters
- $right : int|string
-
The right to compare, can be the right string to look for or an integer.
Return values
bool —True if this user has enough access level.
Compare the access level of this user to the incoming right. $right could be an int (access level) or a string (right)
checkUserInput()
Check if the class could generate a valid object from $input.
public
static checkUserInput(array<string|int, mixed> $input[, array<string|int, string>|null $fields = null ][, PermanentEntity|null $ref = null ][, int &$errCount = 0 ][, bool $ignoreRequired = false ]) : array<string|int, mixed>
The method could modify the user input to fix it, but it must return the data. The data are passed through the validator, for different cases:
- If empty, this function return an empty array.
- If an array, it uses a field => checkMethod association.
Parameters
- $input : array<string|int, mixed>
-
The user input data to check.
- $fields : array<string|int, string>|null = null
-
The array of fields to check. Default value is null.
- $ref : PermanentEntity|null = null
-
The referenced object (update only). Default value is null.
- $errCount : int = 0
-
The resulting error count, as pointer. Output parameter.
- $ignoreRequired : bool = false
Return values
array<string|int, mixed> —The valid data.
create()
Create a new permanent object from ths input data.
public
static create([array<string|int, mixed> $input = [] ][, array<string|int, mixed>|null $fields = null ][, int &$errCount = 0 ]) : int
To create an object, we expect that it is valid, else we throw an exception.
Parameters
- $input : array<string|int, mixed> = []
-
The input data we will check, extract and create the new object.
- $fields : array<string|int, mixed>|null = null
-
The array of fields to check. Default value is null.
- $errCount : int = 0
-
Output parameter to get the number of found errors. Default value is 0
Tags
Return values
int —The ID of the new permanent object.
createAndGet()
Create a new permanent object
public
static createAndGet([array<string|int, mixed> $input = [] ][, array<string|int, mixed>|null $fields = null ][, int &$errCount = 0 ]) : static
Parameters
- $input : array<string|int, mixed> = []
-
The input data we will check, extract and create the new object.
- $fields : array<string|int, mixed>|null = null
-
The array of fields to check. Default value is null.
- $errCount : int = 0
-
Output parameter to get the number of found errors. Default value is 0
Tags
Return values
static —The new permanent object
ei()
Escape identifier through instance
public
static ei([string|null $identifier = null ]) : string
Parameters
- $identifier : string|null = null
-
The identifier to escape. Default is table name.
Tags
Return values
string —The escaped identifier
equals()
Verify equality with another object
public
equals(mixed $other) : bool
Parameters
- $other : mixed
-
The object to compare.
Return values
bool —True if this object represents the same data, else False.
Compare the class and the ID field value of the 2 objects.
escapeIdentifier()
Escape identifier through instance
public
static escapeIdentifier([string|null $identifier = null ]) : string
Parameters
- $identifier : string|null = null
-
The identifier to escape. Default is table name.
Tags
Return values
string —The escaped identifier
fillLogEvent()
Add an $event log in this $array
public
static fillLogEvent(array<string|int, mixed> &$array, string $event) : void
Parameters
- $array : array<string|int, mixed>
- $event : string
findEntityObject()
Get entity instance by type and id
public
static findEntityObject(string $entityType, string $entityId) : PermanentEntity
Parameters
- $entityType : string
- $entityId : string
Return values
PermanentEntityformatValue()
Escape value through instance
public
static formatValue(mixed $value) : string
Parameters
- $value : mixed
-
The value to format
Tags
Return values
string —The formatted $Value
free()
Free the object (remove)
public
free() : bool
Tags
Return values
boolget()
Get some permanent objects Get an objects' list using this class' table.
public
static get([null $options = null ]) : SqlSelectRequest|array<string|int, mixed>|PermanentEntity|null
Take care that output=AbstractSqlAdapter::ARR_OBJECTS and number=1 is different from output=AbstractSqlAdapter::OBJECT
Parameters
- $options : null = null
-
The options used to get the permanents object
Tags
Return values
SqlSelectRequest|array<string|int, mixed>|PermanentEntity|null —An array of array containing object's data
getActiveUser()
Get active user
public
static getActiveUser() : AbstractUser|null
Return values
AbstractUser|null —The user of the current client logged in
getAppRoles()
Get application roles
public
static getAppRoles() : array<string|int, mixed>
Return values
array<string|int, mixed>getAuthenticationToken()
public
abstract getAuthenticationToken() : string
Return values
stringgetByAuthenticationToken()
public
abstract static getByAuthenticationToken(string $token) : static|null
Parameters
- $token : string
Return values
static|nullgetCachedInstance()
public
static getCachedInstance(string $id) : static|null
Parameters
- $id : string
Return values
static|nullgetClass()
Get the name of this class
public
static getClass() : string
Tags
Return values
string —The name of this class.
getCreateOperation()
Get the create operation
public
static getCreateOperation(array<string|int, mixed> $input, array<string|int, string> $fields) : CreateTransactionOperation
Parameters
- $input : array<string|int, mixed>
-
The input data we will check and extract, used by children
- $fields : array<string|int, string>
-
The array of fields to check
Return values
CreateTransactionOperationgetDeleteOperation()
Get the delete operation for this object
public
getDeleteOperation() : DeleteTransactionOperation
Return values
DeleteTransactionOperationgetDescriptor()
public
static getDescriptor() : EntityDescriptor
Return values
EntityDescriptorgetDomain()
Get the domain of this class, can be guessed from $table or specified in $domain.
public
static getDomain() : string
Return values
string —The domain of this class.
getEntity()
Get this entity name
public
static getEntity() : string
Return values
stringgetEntityWhereClause()
Helper method to get whereClause string from an entity
public
getEntityWhereClause([string $prefix = '' ]) : string
Parameters
- $prefix : string = ''
-
The prefix for fields, e.g "table." (with dot)
Return values
string —Helper method to get whereClause string from an entity. The related entity should have entity_type and entity_id fields.
getField()
Get field descriptor from field name
public
static getField(string $field) : FieldDescriptor
Parameters
- $field : string
Return values
FieldDescriptorgetFields()
Get the available fields of this entity
public
static getFields() : array<string|int, string>
Return values
array<string|int, string> —The available fields in entity
getIdField()
Get the ID field name of this entity
public
static getIdField() : string
Return values
string —The ID field
getLabel()
public
getLabel() : string
Return values
stringgetLogEvent()
Build a new log event for $event for this time and the user IP address.
public
static getLogEvent(string $event[, mixed|null $time = null ][, string|null $ipAddress = null ]) : array<string|int, mixed>
Parameters
- $event : string
-
The event to log in this object
- $time : mixed|null = null
-
A specified time to use for logging event
- $ipAddress : string|null = null
-
A specified IP Address to use for logging event
Tags
Return values
array<string|int, mixed>getLoggedUserId()
Get ID if user is logged
public
static getLoggedUserId() : string
Return values
string —The id of the current client logged in
getMetadata()
public
static getMetadata() : EntityMetadata|null
Return values
EntityMetadata|nullgetReference()
public
getReference() : string
Return values
stringgetRoleAccessLevel()
Get access level of a role
public
static getRoleAccessLevel(string $role) : int
Parameters
- $role : string
Return values
intgetSqlAdapter()
Get the SQL Adapter of this class
public
static getSqlAdapter() : AbstractSqlAdapter
Tags
Return values
AbstractSqlAdaptergetTable()
Get the table of this class
public
static getTable() : string
Return values
string —The table of this class.
getUpdateOperation()
Get the update operation
public
getUpdateOperation(array<string|int, mixed> $input, array<string|int, string> $fields) : UpdateTransactionOperation
Parameters
- $input : array<string|int, mixed>
-
The input data we will check and extract, used by children
- $fields : array<string|int, string>
-
The array of fields to check
Return values
UpdateTransactionOperationgetUserAccess()
Get user access If anonymous, the user access is -1 (below zero)
public
static getUserAccess() : int
Return values
intgetUserByLogin()
public
static getUserByLogin(string|null $login, string|null $password) : mixed
Parameters
- $login : string|null
- $password : string|null
getUserClass()
public
static getUserClass() : string|null
Return values
string|nullgetUserRoles()
Get all user roles
public
static getUserRoles() : array<string|int, mixed>
Return values
array<string|int, mixed>getValue()
Get the value of field $key or all data values if $key is null.
public
getValue([string|null $key = null ]) : mixed
Parameters
- $key : string|null = null
-
Name of the field to get.
hasChanges()
public
hasChanges() : bool
Return values
boolhasRoleAccessLevel()
Check user can use the role's permission
public
hasRoleAccessLevel(string $role) : bool
Parameters
- $role : string
Tags
Return values
boolid()
Get this permanent object's ID
public
id() : string
Return values
string —The id of this object.
initialize()
Initialize entity class You must call this method after the class declaration
public
static initialize(string $name) : void
Parameters
- $name : string
Tags
initializeWithDescriptor()
public
static initializeWithDescriptor(EntityDescriptor $descriptor) : void
Parameters
- $descriptor : EntityDescriptor
isAdmin()
public
isAdmin() : bool
Return values
boolisDeleted()
Check if this object is deleted
public
isDeleted() : bool
Return values
bool —True if this object is deleted
Checks if this object is known as deleted.
isUserAdmin()
Checks if this user has admin access level.
public
static isUserAdmin() : bool
This is often used to determine if the current user can access to the admin panel.
Return values
bool —True if this user is logged and is admin
isValid()
Check if this object is valid
public
isValid() : bool
Return values
bool —True if this object is valid
Check if this object is not deleted. May be used for others cases.
listKnownEntities()
List all known entities
public
static listKnownEntities() : array<string|int, string>
Return values
array<string|int, string>listLoginFields()
List all available login fields
public
static listLoginFields() : array<string|int, string>
Return values
array<string|int, string>load()
Loads the object with the ID $id or the array data.
public
static load(mixed $id[, bool $nullable = true ][, bool $useCache = true ]) : PermanentEntity|null
The return value is always a static object (no null, no array, no other object).
Parameters
- $id : mixed
-
The object ID to load or a valid array of the object's data
- $nullable : bool = true
-
True to silent errors row and return null
- $useCache : bool = true
-
True to cache load and set cache, false to not cache
Tags
Return values
PermanentEntity|null —The object loaded from database
loadEntity()
Try to load entity from an entity string and an id integer
public
static loadEntity(string $entity, string $id) : PermanentEntity|null
Parameters
- $entity : string
- $id : string
Return values
PermanentEntity|nulllogEvent()
Log an event
public
logEvent(string $event[, mixed $time = null ][, string|null $ipAdd = null ]) : void
Parameters
- $event : string
-
The event to log in this object
- $time : mixed = null
-
A specified time to use for logging event
- $ipAdd : string|null = null
-
A specified IP Address to use for logging event
Tags
loggedCanAccessToRoute()
Check if this user can access to a module
public
static loggedCanAccessToRoute(string $route, string|int $accessLevel) : bool
Parameters
- $route : string
-
The route to look for
- $accessLevel : string|int
-
The access level
Return values
bool —True if this user can access to $module
loggedCanDo()
Check if this user can do a restricted action
public
static loggedCanDo(string $action[, AbstractUser|null $object = null ]) : bool
Parameters
- $action : string
-
The action to look for
- $object : AbstractUser|null = null
-
The object to edit if editing one or null. Default value is null
Tags
Return values
bool —True if this user can do this $action
loggedHasDeveloperAccess()
Check if this user has developer access
public
static loggedHasDeveloperAccess() : bool
Return values
bool —True if this user has developer access
markAsDeleted()
Mark this object as deleted
public
markAsDeleted() : static
Tags
Return values
staticobject()
Get the object whatever we give to it
public
static object(PermanentEntity|string &$entity) : static|int|null
Parameters
- $entity : PermanentEntity|string
Tags
Return values
static|int|nullonAuthenticated()
Callback when user is authenticated
public
onAuthenticated() : mixed
onEdit()
public
static onEdit(array<string|int, mixed> &$input, PermanentEntity|null $object) : void
Parameters
- $input : array<string|int, mixed>
- $object : PermanentEntity|null
onSaved()
Callback when object was saved
public
static onSaved(array<string|int, mixed> $data, PermanentEntity|int $object) : void
Parameters
- $data : array<string|int, mixed>
- $object : PermanentEntity|int
onValidCreate()
Callback when validating create
public
static onValidCreate(array<string|int, mixed> &$input, int &$newErrors) : bool
Parameters
- $input : array<string|int, mixed>
- $newErrors : int
Return values
boolonValidEdit()
Callback when validating create
public
static onValidEdit(array<string|int, mixed> $input, PermanentEntity|null $object, int &$newErrors) : bool
Parameters
- $input : array<string|int, mixed>
- $object : PermanentEntity|null
- $newErrors : int
Return values
boolonValidUpdate()
Callback when validating update
public
static onValidUpdate(array<string|int, mixed> &$input, int $newErrors) : bool
Parameters
- $input : array<string|int, mixed>
- $newErrors : int
Return values
boolputValue()
Validate field value and set it
public
putValue(string $field, mixed $value) : void
Parameters
- $field : string
- $value : mixed
Tags
registerEntity()
Register an entity
public
static registerEntity(string $class) : void
Parameters
- $class : string
reload()
Reload fields from database Also it removes the reloaded fields from the modified ones list.
public
reload() : bool
Return values
boolremove()
What do you think it does ?
public
remove() : bool
Return values
boolreportException()
Report an UserException
public
static reportException(UserException $e) : void
Parameters
- $e : UserException
-
the user exception
Tags
requestInsert()
Get insert query
public
static requestInsert() : SqlInsertRequest
Tags
Return values
SqlInsertRequest —The query
requestSelect()
Get select query
public
static requestSelect() : SqlSelectRequest
Tags
Return values
SqlSelectRequest —The query
requestUpdate()
Get update query
public
static requestUpdate() : SqlUpdateRequest
Tags
Return values
SqlUpdateRequest —The query
requireAuthenticatedUserId()
public
static requireAuthenticatedUserId() : int
Return values
intrevert()
public
revert() : PermanentEntity
Return values
PermanentEntitysave()
Save current changes of this entity to the database Input is NOT validated here, we recommend it for programming changes only
public
save() : bool|int
Tags
Return values
bool|int —True in case of success
setCheckFieldIntegrity()
Serve to bypass the integrity check, should be only used while developing
public
static setCheckFieldIntegrity(bool $checkFieldIntegrity) : void
Parameters
- $checkFieldIntegrity : bool
setUserClass()
public
static setUserClass([string|null $userClass = null ]) : mixed
Parameters
- $userClass : string|null = null
setValue()
Set the field $key with the new $value.
public
setValue(string $key, mixed $value) : $this
Parameters
- $key : string
-
Name of the field to set
- $value : mixed
-
New value of the field
Tags
Return values
$thistestUserInput()
Test user input
public
static testUserInput(array<string|int, mixed> $input[, array<string|int, mixed>|null $fields = null ][, PermanentEntity|null $ref = null ][, int &$errCount = 0 ][, array<string|int, mixed>|bool $ignoreRequired = false ]) : bool
Parameters
- $input : array<string|int, mixed>
-
The new data to process.
- $fields : array<string|int, mixed>|null = null
-
The array of fields to check. Default value is null.
- $ref : PermanentEntity|null = null
-
The referenced object (update only). Default value is null.
- $errCount : int = 0
-
The resulting error count, as pointer. Output parameter.
- $ignoreRequired : array<string|int, mixed>|bool = false
Tags
Return values
booltext()
Translate text according to the object domain
public
static text(string $text[, array<string|int, mixed> $values = [] ]) : string
Parameters
- $text : string
-
The text to translate
- $values : array<string|int, mixed> = []
-
The values array to replace in text. Could be used as second parameter.
Tags
Return values
string —The translated text
throwException()
Throws an UserException with the current domain
public
static throwException(string $message) : void
Parameters
- $message : string
-
the text message, may be a translation string
Tags
throwNotFound()
Throws an NotFoundException with the current domain
public
static throwNotFound([string|null $message = null ]) : mixed
Parameters
- $message : string|null = null
-
the text message, may be a translation string
Tags
uid()
Get this permanent object's unique ID
public
uid() : string
Return values
string —The uid of this object.
Get this object ID according to the table and id.
update()
Update this permanent entity from input data array Parameter $fields is really useful to allow partial modification only (against form hack).
public
update(array<string|int, mixed> $input, array<string|int, string> $fields[, int &$errCount = 0 ]) : bool
Input is validated here, we recommend it for forms
Parameters
- $input : array<string|int, mixed>
-
The input data we will check and extract, used by children
- $fields : array<string|int, string>
-
The array of fields to check
- $errCount : int = 0
-
Output parameter for the number of occurred errors validating fields.
Return values
boolvalidateValue()
Validate field value from the validator using this entity
public
validateValue(string $field, mixed $value) : void
Parameters
- $field : string
- $value : mixed
verifyConflicts()
Check for object
public
static verifyConflicts(array<string|int, mixed> $data[, PermanentEntity|string $object = null ]) : void
This function is called by create() after checking user input data and before running for them. In the base class, this method does nothing.
Parameters
- $data : array<string|int, mixed>
-
The new data to process.
- $object : PermanentEntity|string = null
-
The referenced object (update only). Default value is null.
Tags
checkCache()
Check if this object is cached and cache it
protected
checkCache() : static
Return values
staticformatFieldSqlValue()
Format the value from PHP type to SQL scalar
protected
static formatFieldSqlValue(string $name, mixed $value) : mixed
Parameters
- $name : string
-
The field name to format
- $value : mixed
-
The field value to format
Return values
mixed —The formatted $Value
getExportData()
Get data with an exportable format.
protected
getExportData([array<string|int, string>|null $filterKeys = null ]) : array<string|int, mixed>
We recommend to filter only data you need using $filterKeys
Parameters
- $filterKeys : array<string|int, string>|null = null
-
The key to filter, else all
Return values
array<string|int, mixed>instantiate()
Instantiate object from data, allowing you to instantiate child class
protected
static instantiate(array<string|int, mixed> $data[, bool $useCache = true ]) : static
Parameters
- $data : array<string|int, mixed>
- $useCache : bool = true
Return values
staticparseFieldSqlValue()
Parse the value from SQL scalar to PHP type
protected
static parseFieldSqlValue(string $name, string|null $value) : mixed
Parameters
- $name : string
-
The field name to parse
- $value : string|null
-
The field value to parse
Return values
mixed —The parsed value
setCachedInstance()
protected
static setCachedInstance(PermanentEntity $instance) : void
Parameters
- $instance : PermanentEntity
setData()
Set all data of object (internal use only)
protected
setData(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>