Orpheus

EntityDescriptor
in package

A class to describe an entity

Tags
author

Florent Hazard contact@sowapps.com

This class uses a Yaml configuration file to describe the entity. Thus, you can easily update your database using dev_entities module, and it validates the input data for you.

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

Properties

$idField

The ID field

protected string $idField = self::DEFAULT_FIELD_ID

$indexes

The indexes of this entity

protected array<string|int, string> $indexes = []

$typeClasses

All known types

protected static array<string|int, mixed> $typeClasses = []

Methods

getFieldsName()

Get fields' name

public getFieldsName() : array<string|int, string>
Return values
array<string|int, string>

getIndexes()

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

isAbstract()

Is this entity abstract ?

public isAbstract() : bool
Return values
bool

True if abstract

parseType()

parse type from configuration string

public static parseType(string $desc) : object
Parameters
$desc : string
Tags
throws
Exception
Return values
object

registerType()

Register a AbstractTypeDescriptor

public static registerType(string $name, string $class) : void
Parameters
$name : string
$class : string

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
noinspection

PhpRedundantCatchClauseInspection

__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

							
On this page

Search results