PHP Class Bolt\Storage\Field\Type\FieldTypeBase

Author: Ross Riley ([email protected])
Inheritance: implements Bolt\Storage\Field\Type\FieldTypeInterface, implements Bolt\Storage\Field\FieldInterface, use trait Bolt\Storage\CaseTransformTrait
Show file Open project: bolt/bolt Class Usage Examples

Public Properties

Property Type Description
$mapping

Protected Properties

Property Type Description
$em
$platform

Public Methods

Method Description
__construct ( array $mapping = [], EntityManager $em = null )
get ( $entity ) : mixed Reads the current value of the field from an entity and returns value
getMappingAttribute ( ) : string Gets the entity attribute name to be used for reading / persisting
getName ( )
getPlatform ( ) : Doctrine\DBAL\Platforms\AbstractPlatform Returns the platform
getStorageOptions ( )
getStorageType ( ) : Doctrine\DBAL\Types\Type Returns the name of the Doctrine storage type to use for a field.
getTemplate ( ) Provides a template that is able to render the field
hydrate ( $data, $entity )
load ( Doctrine\DBAL\Query\QueryBuilder $query, Bolt\Storage\Mapping\ClassMetadata $metadata )
persist ( Bolt\Storage\QuerySet $queries, $entity )
present ( $entity )
query ( Bolt\Storage\Query\QueryInterface $query, Bolt\Storage\Mapping\ClassMetadata $metadata )
set ( object $entity, mixed $value ) The set method takes a raw php value and performs the conversion to the entity value.
setPlatform ( Doctrine\DBAL\Platforms\AbstractPlatform $platform ) Sets the current platform to an instance of AbstractPlatform

Protected Methods

Method Description
isJson ( mixed $value ) : boolean Check if a value is a JSON string.
normalizeData ( $data, $field )
rewriteQueryFilterParameters ( Filter $filter, Bolt\Storage\Query\QueryInterface $query, $field, $column ) This method does an in-place modification of a generic contenttype.field query to the format actually used in the raw sql category. For instance a simple query might say entries.tags = 'movies' but now we are in the context of entries the actual SQL fragment needs to be tags.slug = 'movies'. We don't know this until we drill down to the individual field types so this rewrites the SQL fragment just before the query gets sent.

Method Details

__construct() public method

public __construct ( array $mapping = [], EntityManager $em = null )
$mapping array
$em Bolt\Storage\EntityManager

get() public method

Reads the current value of the field from an entity and returns value
public get ( $entity ) : mixed
$entity
return mixed

getMappingAttribute() public method

Gets the entity attribute name to be used for reading / persisting
public getMappingAttribute ( ) : string
return string

getName() public method

public getName ( )

getPlatform() public method

Returns the platform
public getPlatform ( ) : Doctrine\DBAL\Platforms\AbstractPlatform
return Doctrine\DBAL\Platforms\AbstractPlatform

getStorageOptions() public method

Deprecation: Here to maintain compatibility with the old interface
public getStorageOptions ( )

getStorageType() public method

Returns the name of the Doctrine storage type to use for a field.
public getStorageType ( ) : Doctrine\DBAL\Types\Type
return Doctrine\DBAL\Types\Type

getTemplate() public method

Provides a template that is able to render the field
Deprecation:
public getTemplate ( )

hydrate() public method

public hydrate ( $data, $entity )

isJson() protected method

Check if a value is a JSON string.
protected isJson ( mixed $value ) : boolean
$value mixed
return boolean

load() public method

public load ( Doctrine\DBAL\Query\QueryBuilder $query, Bolt\Storage\Mapping\ClassMetadata $metadata )
$query Doctrine\DBAL\Query\QueryBuilder
$metadata Bolt\Storage\Mapping\ClassMetadata

normalizeData() protected method

protected normalizeData ( $data, $field )

persist() public method

public persist ( Bolt\Storage\QuerySet $queries, $entity )
$queries Bolt\Storage\QuerySet

present() public method

public present ( $entity )

query() public method

public query ( Bolt\Storage\Query\QueryInterface $query, Bolt\Storage\Mapping\ClassMetadata $metadata )
$query Bolt\Storage\Query\QueryInterface
$metadata Bolt\Storage\Mapping\ClassMetadata

rewriteQueryFilterParameters() protected method

Note, reflection is used to achieve this, it is not ideal, but the CompositeExpression shipped with DBAL chooses to keep the query parts as private and only allow access to the final computed string.
protected rewriteQueryFilterParameters ( Filter $filter, Bolt\Storage\Query\QueryInterface $query, $field, $column )
$filter Bolt\Storage\Query\Filter
$query Bolt\Storage\Query\QueryInterface
$field
$column

set() public method

Normally this is as simple as $entity->$key = $value although more complicated transforms can happen should a field type choose to override this method. Note too that this will also be the default method called for an entity builder which is designed to receive raw data to initialise an entity.
public set ( object $entity, mixed $value )
$entity object
$value mixed

setPlatform() public method

Sets the current platform to an instance of AbstractPlatform
public setPlatform ( Doctrine\DBAL\Platforms\AbstractPlatform $platform )
$platform Doctrine\DBAL\Platforms\AbstractPlatform

Property Details

$em protected property

protected $em

$mapping public property

public $mapping

$platform protected property

protected $platform