PHP Class CRUDlex\Entity

With this objects, the data is passed arround and validated.
Mostra file Open project: philiplb/crudlex Class Usage Examples

Protected Properties

Property Type Description
$definition The {@see EntityDefinition} defining how this entity looks like.
$entity Holds the key value data of the entity.

Public Methods

Method Description
__construct ( EntityDefinition $definition ) Constructor.
get ( string $field ) : mixed Gets the value of a field in its specific type.
getDefinition ( ) : EntityDefinition Gets the entity definition.
getRaw ( string $field ) : mixed Gets the raw value of a field no matter what type it is.
populateViaRequest ( Request $request ) Populates the entities fields from the requests parameters.
set ( string $field, mixed $value ) Sets a field value pair of this entity.

Protected Methods

Method Description
toType ( mixed $value, string $type ) : mixed Converts a given value to the given type.

Method Details

__construct() public method

Constructor.
public __construct ( EntityDefinition $definition )
$definition EntityDefinition the definition how this entity looks

get() public method

Gets the value of a field in its specific type.
public get ( string $field ) : mixed
$field string the field
return mixed null on invalid field, an integer if the definition says that the type of the field is an integer, a boolean if the field is a boolean or else the raw value

getDefinition() public method

Gets the entity definition.
public getDefinition ( ) : EntityDefinition
return EntityDefinition the definition

getRaw() public method

This is usefull for input validation for example.
public getRaw ( string $field ) : mixed
$field string the field
return mixed null on invalid field or else the raw value

populateViaRequest() public method

Populates the entities fields from the requests parameters.
public populateViaRequest ( Request $request )
$request Symfony\Component\HttpFoundation\Request the request to take the field data from

set() public method

Sets a field value pair of this entity.
public set ( string $field, mixed $value )
$field string the field
$value mixed the value

toType() protected method

Converts a given value to the given type.
protected toType ( mixed $value, string $type ) : mixed
$value mixed the value to convert
$type string the type to convert to like 'integer' or 'float'
return mixed the converted value

Property Details

$definition protected_oe property

The {@see EntityDefinition} defining how this entity looks like.
protected $definition

$entity protected_oe property

Holds the key value data of the entity.
protected $entity