Converts an entity's values to/from storage types.
Protected Properties | |
string[] | $dehydrate |
Maps complex types to storage types. More... | |
string[] | $foreign = [] |
Properties that are foreign keys to other entities. More... | |
string[] | $hydrate = [] |
The specific classes used to hydrate classed properties, like DateTime . More... | |
string[] | $storageTypes = [] |
Scalar storage types, after any dehydration is done. More... | |
DateTimeZone | $utc |
Protected Properties inherited from Reflection | |
ReflectionClass | $class |
string[] | $columns |
DB | $db |
array | $defaults = [] |
ReflectionProperty[] | $properties = [] |
const | RX_EAV = '/\*\h*@eav\h+(?<table>\w+)/i' |
const | RX_EAV_VAR = '/\*\h*@var\h+(?<type>\w+)\[\]/i' |
const | RX_FOREIGN = '/\*\h*@foreign\h+(?<column>\w+)\h+(?<class>\S+)/i' |
const | RX_IS_COLUMN = '/\*\h*@col(umn)?\b/i' |
const | RX_JUNCTION = '/\*\h*@junction\h+(?<table>\w+)/i' |
const | RX_NULL = '/(\bnull\|)|(\|null\b)/i' |
const | RX_RECORD = '/\*\h*@record\h+(?<table>\w+)/i' |
const | RX_UNIQUE = '/^\h*\*\h*@unique\h*$/im' |
const | RX_UNIQUE_GROUP = '/^\h*\*\h*@unique\h+(?<ident>[a-z_]+)\h*$/im' |
const | RX_VAR = '/\*\h*@var\h+(?<type>\S+)/i' |
Public Methods | |
__construct (DB $db, $class) | |
array | export (EntityInterface $entity) |
Returns an entity's property values, dehydrating if needed. More... | |
string[] | getForeign () |
string[] | getStorageTypes () |
Returns the scalar storage types of all properties. More... | |
void | import (EntityInterface $entity, array $values) |
Sets values from storage on an entity, hydrating if needed. More... | |
Public Methods inherited from Reflection | |
string[] | getColumns () |
EAV[] | getEav () |
string[] | getForeignClasses () |
Classes keyed by column. More... | |
string | getJunctionTable () |
string | getRecordTable () |
string | getType (string $property) |
Scalar storage type, or FQN of a complex type. More... | |
string[] | getUnique () |
Columns with their own individual unique constraints. More... | |
string[][] | getUniqueGroups () |
Table-level (multi-column) constraints are grouped under an arbitrary shared identifier. More... | |
mixed | getValue (object $object, string $property) |
Gets and returns a value through reflection. More... | |
bool | isColumn (string $property) |
bool | isNullable (string $property) |
Whether a property allows NULL as a value. More... | |
bool | isUnique (string $column) |
bool | isUniqueMulti (string $column, &$ident=null) |
object | newProto () |
void | setValue (object $object, string $property, $value) |
Sets a value through reflection. More... | |
Protected Methods | |
null scalar | dehydrate (string $to, string $from, $hydrated) |
Dehydrates a complex property's value for storage in a scalar column. More... | |
array object | hydrate (string $to, string $from, $dehydrated) |
Hydrates a complex value from scalar storage. More... | |
Additional Inherited Members | |
Public Properties inherited from Reflection | |
const | SCALARS |
Maps annotated/native scalar types to storage types acceptable for settype() More... | |
Public Static Methods inherited from Reflection | |
magic static self | factory (DB $db, string|object $class) |
|
protected |
Maps complex types to storage types.
Foreign EntityInterface columns are automatically added as "int"
|
protected |
Properties that are foreign keys to other entities.
[ property => foreign entity class ]
|
protected |
The specific classes used to hydrate classed properties, like DateTime
.
[ property => class ]
|
protected |
Scalar storage types, after any dehydration is done.
[property => type]
__construct | ( | DB | $db, |
$class | |||
) |
DB | $db | |
string | object | $class |
Reimplemented from Reflection.
|
protected |
Dehydrates a complex property's value for storage in a scalar column.
string | $to | The storage type. |
string | $from | The strict type from the class definition. |
array | object | $hydrated |
array export | ( | EntityInterface | $entity | ) |
Returns an entity's property values, dehydrating if needed.
EntityInterface | $entity |
|
final |
|
final |
Returns the scalar storage types of all properties.
This doesn't include whether the properties are nullable. Use Serializer::isNullable() for that.
|
protected |
Hydrates a complex value from scalar storage.
string | $to | The strict type from the class definition. |
string | $from | The storage type. |
scalar | $dehydrated |
void import | ( | EntityInterface | $entity, |
array | $values | ||
) |
Sets values from storage on an entity, hydrating if needed.
EntityInterface | $entity | |
array | $values |