EntityDescriptor
in package
A class to describe an entity
Tags
Table of Contents
Constants
- CACHE_DESCRIPTOR = 'entity-descriptor'
- DEFAULT_FIELD_ID = 'id'
- FLAG_ABSTRACT = 'abstract'
- VERSION = 5
Properties
- $abstract : bool
- Is this entity abstract ?
- $class : string|null
- The class associated to this entity
- $domain : string|null
- The domain used by entity
- $fields : array<string|int, FieldDescriptor>
- The fields of this entity
- $idField : string
- The ID field
- $indexes : array<string|int, string>
- The indexes of this entity
- $name : string
- The entity's name
- $table : string|null
- The table
- $typeClasses : array<string|int, mixed>
- All known types
- $version : int
- The entity's version
Methods
- build() : EntityDescriptor
- getClass() : string|null
- getDomain() : string|null
- getField() : FieldDescriptor|null
- Get one field by name
- getFields() : array<string|int, FieldDescriptor>
- Get all fields
- getFieldsName() : array<string|int, string>
- Get fields' name
- getIdField() : string
- getIndexes() : array<string|int, object>
- Get all indexes
- getName() : string
- Get the name of the entity
- getTable() : string|null
- getType() : AbstractTypeDescriptor
- Get a type by name
- isAbstract() : bool
- Is this entity abstract ?
- load() : EntityDescriptor
- Load an entity descriptor from configuration file
- parseType() : object
- parse type from configuration string
- registerType() : void
- Register a AbstractTypeDescriptor
- setAbstract() : EntityDescriptor
- Set the abstract property of this entity
- setClass() : void
- setDomain() : void
- setIdField() : void
- setTable() : void
- validate() : array<string|int, mixed>
- Validate input
- validateFieldValue() : void
- Validate a value for a specified field, an exception is thrown if the value is invalid We should always take care about idempotence of the value, it could be a string typed by user or a final DateTime it validates explicitly then parse value to ensure the value is valid
- __construct() : mixed
- Construct the entity descriptor
Constants
CACHE_DESCRIPTOR
public
mixed
CACHE_DESCRIPTOR
= 'entity-descriptor'
DEFAULT_FIELD_ID
public
mixed
DEFAULT_FIELD_ID
= 'id'
FLAG_ABSTRACT
public
mixed
FLAG_ABSTRACT
= 'abstract'
VERSION
public
mixed
VERSION
= 5
Properties
$abstract
Is this entity abstract ?
protected
bool
$abstract
= false
$class
The class associated to this entity
protected
string|null
$class
$domain
The domain used by entity
protected
string|null
$domain
= null
$fields
The fields of this entity
protected
array<string|int, FieldDescriptor>
$fields
= []
$idField
The ID field
protected
string
$idField
= self::DEFAULT_FIELD_ID
$indexes
The indexes of this entity
protected
array<string|int, string>
$indexes
= []
$name
The entity's name
protected
string
$name
$table
The table
protected
string|null
$table
= null
$typeClasses
All known types
protected
static array<string|int, mixed>
$typeClasses
= []
$version
The entity's version
protected
int
$version
Methods
build()
public
static build(string $name, object $config[, string|null $class = null ]) : EntityDescriptor
Parameters
- $name : string
- $config : object
- $class : string|null = null
Tags
Return values
EntityDescriptorgetClass()
public
getClass() : string|null
Return values
string|nullgetDomain()
public
getDomain() : string|null
Return values
string|nullgetField()
Get one field by name
public
getField(string $name) : FieldDescriptor|null
Parameters
- $name : string
-
The field name
Return values
FieldDescriptor|nullgetFields()
Get all fields
public
getFields() : array<string|int, FieldDescriptor>
Return values
array<string|int, FieldDescriptor>getFieldsName()
Get fields' name
public
getFieldsName() : array<string|int, string>
Return values
array<string|int, string>getIdField()
public
getIdField() : string
Return values
stringgetIndexes()
Get all indexes
public
getIndexes() : array<string|int, object>
Return values
array<string|int, object>getName()
Get the name of the entity
public
getName() : string
Return values
string —The name of the descriptor
getTable()
public
getTable() : string|null
Return values
string|nullgetType()
Get a type by name
public
static getType(string $name) : AbstractTypeDescriptor
Parameters
- $name : string
-
Name of the type to get
Return values
AbstractTypeDescriptorisAbstract()
Is this entity abstract ?
public
isAbstract() : bool
Return values
bool —True if abstract
load()
Load an entity descriptor from configuration file
public
static load(string $name[, string|null $class = null ]) : EntityDescriptor
Parameters
- $name : string
- $class : string|null = null
Tags
Return values
EntityDescriptorparseType()
parse type from configuration string
public
static parseType(string $desc) : object
Parameters
- $desc : string
Tags
Return values
objectregisterType()
Register a AbstractTypeDescriptor
public
static registerType(string $name, string $class) : void
Parameters
- $name : string
- $class : string
setAbstract()
Set the abstract property of this entity
public
setAbstract(bool $abstract) : EntityDescriptor
Parameters
- $abstract : bool
-
True to set descriptor as abstract
Return values
EntityDescriptor —the descriptor
setClass()
public
setClass(string $class) : void
Parameters
- $class : string
setDomain()
public
setDomain(string|null $domain) : void
Parameters
- $domain : string|null
setIdField()
public
setIdField(string $idField) : void
Parameters
- $idField : string
setTable()
public
setTable(string|null $table) : void
Parameters
- $table : string|null
validate()
Validate input
public
validate(array<string|int, mixed> &$input[, array<string|int, mixed>|null $fields = null ][, PermanentEntity|null $ref = null ][, int &$errCount = 0 ][, bool|array<string|int, mixed> $ignoreRequired = false ]) : array<string|int, mixed>
Parameters
- $input : array<string|int, mixed>
- $fields : array<string|int, mixed>|null = null
- $ref : PermanentEntity|null = null
- $errCount : int = 0
- $ignoreRequired : bool|array<string|int, mixed> = false
Return values
array<string|int, mixed>validateFieldValue()
Validate a value for a specified field, an exception is thrown if the value is invalid We should always take care about idempotence of the value, it could be a string typed by user or a final DateTime it validates explicitly then parse value to ensure the value is valid
public
validateFieldValue(string $fieldName, mixed &$value[, array<string|int, string> $input = [] ][, PermanentEntity|null $ref = null ]) : void
Parameters
- $fieldName : string
-
The field to use
- $value : mixed
-
input|output value to validate for this field
- $input : array<string|int, string> = []
- $ref : PermanentEntity|null = null
Tags
__construct()
Construct the entity descriptor
protected
__construct(string $name, array<string|int, FieldDescriptor> $fields, array<string|int, object> $indexes[, string|null $class = null ]) : mixed
Parameters
- $name : string
- $fields : array<string|int, FieldDescriptor>
- $indexes : array<string|int, object>
- $class : string|null = null