PHP Класс CRUDlex\Entity

With this objects, the data is passed arround and validated.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$definition The {@see EntityDefinition} defining how this entity looks like.
$entity Holds the key value data of the entity.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
toType ( mixed $value, string $type ) : mixed Converts a given value to the given type.

Описание методов

__construct() публичный Метод

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

get() публичный Метод

Gets the value of a field in its specific type.
public get ( string $field ) : mixed
$field string the field
Результат 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() публичный Метод

Gets the entity definition.
public getDefinition ( ) : EntityDefinition
Результат EntityDefinition the definition

getRaw() публичный Метод

This is usefull for input validation for example.
public getRaw ( string $field ) : mixed
$field string the field
Результат mixed null on invalid field or else the raw value

populateViaRequest() публичный Метод

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() публичный Метод

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

toType() защищенный Метод

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'
Результат mixed the converted value

Описание свойств

$definition защищенное свойство

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

$entity защищенное свойство

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