PHP Class Bolt\Storage\Entity\Builder

Show file Open project: bolt/bolt Class Usage Examples

Protected Properties

Property Type Description
$class string The class to use for new instances.
$classMetadata
$fieldManager
$metadata
$transformers

Public Methods

Method Description
__construct ( MetadataDriver $metadata, FieldManager $fieldManager ) Constructor.
create ( array | object $data, object | null $entity = null ) : object Creates a new entity object.
createFromDatabaseValues ( array $data, object | null $entity = null ) : object Performs database to PHP transforms before creating new entity.
getClassMetadata ( ) : Bolt\Storage\Mapping\ClassMetadata Gets the metadata instance.
getEntity ( object | null $entity = null ) : object Returns a new empty entity class.
getFields ( ) : array Uses either the class default or the supplied ClassMetadata to return a list of fields for this entity.
getHydratedValue ( $value, $field, null $subField = null ) : Bolt\Storage\Entity\FieldValue | boolean
refresh ( object | null $entity ) Refresh an entities values.
setClass ( string $class ) Sets the entity class that will be built.
setClassMetadata ( Bolt\Storage\Mapping\ClassMetadata $classMetadata ) Sets the metadata for the class to be built.
setTransformer ( string $fieldTypeClass, callable $handler ) Adds a transformer for a specific field type.

Method Details

__construct() public method

Constructor.
public __construct ( MetadataDriver $metadata, FieldManager $fieldManager )
$metadata Bolt\Storage\Mapping\MetadataDriver
$fieldManager Bolt\Storage\FieldManager

create() public method

Creates a new entity object.
public create ( array | object $data, object | null $entity = null ) : object
$data array | object Data to load into the entity.
$entity object | null
return object $entity

createFromDatabaseValues() public method

Performs database to PHP transforms before creating new entity.
public createFromDatabaseValues ( array $data, object | null $entity = null ) : object
$data array
$entity object | null
return object $entity

getClassMetadata() public method

Gets the metadata instance.
public getClassMetadata ( ) : Bolt\Storage\Mapping\ClassMetadata
return Bolt\Storage\Mapping\ClassMetadata $classMetadata

getEntity() public method

Returns a new empty entity class.
public getEntity ( object | null $entity = null ) : object
$entity object | null
return object

getFields() public method

Uses either the class default or the supplied ClassMetadata to return a list of fields for this entity.
public getFields ( ) : array
return array

getHydratedValue() public method

public getHydratedValue ( $value, $field, null $subField = null ) : Bolt\Storage\Entity\FieldValue | boolean
$value
$field
$subField null
return Bolt\Storage\Entity\FieldValue | boolean

refresh() public method

Refresh an entities values.
public refresh ( object | null $entity )
$entity object | null

setClass() public method

Sets the entity class that will be built.
public setClass ( string $class )
$class string

setClassMetadata() public method

Sets the metadata for the class to be built.
public setClassMetadata ( Bolt\Storage\Mapping\ClassMetadata $classMetadata )
$classMetadata Bolt\Storage\Mapping\ClassMetadata

setTransformer() public method

Adds a transformer for a specific field type.
public setTransformer ( string $fieldTypeClass, callable $handler )
$fieldTypeClass string Class of the field type to transform
$handler callable

Property Details

$class protected property

The class to use for new instances.
protected string $class
return string

$classMetadata protected property

protected $classMetadata

$fieldManager protected property

protected $fieldManager

$metadata protected property

protected $metadata

$transformers protected property

protected $transformers