PHP Class CRUDlex\Entity

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

Protected Properties

Свойство Type Description
$definition The {@see EntityDefinition} defining how this entity looks like.
$entity Holds the key value data of the entity.

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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

get() public méthode

Gets the value of a field in its specific type.
public get ( string $field ) : mixed
$field string the field
Résultat 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 méthode

Gets the entity definition.
public getDefinition ( ) : EntityDefinition
Résultat EntityDefinition the definition

getRaw() public méthode

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

populateViaRequest() public méthode

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 méthode

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

toType() protected méthode

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'
Résultat 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