PHP Class Bolt\Storage\Field\Type\RelationType

Author: Ross Riley ([email protected])
Author: Gawain Lynch ([email protected])
Inheritance: extends FieldTypeBase
Show file Open project: bolt/bolt

Public Methods

Method Description
getName ( )
hydrate ( $data, $entity )
load ( Doctrine\DBAL\Query\QueryBuilder $query, Bolt\Storage\Mapping\ClassMetadata $metadata ) : void For relations, the load method adds an extra ->addSelect() and ->leftJoin() to the query that fetches the related records from the join table in the same query as the content fetch.
persist ( Bolt\Storage\QuerySet $queries, $entity )
query ( Bolt\Storage\Query\QueryInterface $query, Bolt\Storage\Mapping\ClassMetadata $metadata ) : void Relation fields can allow filters on the relations fetched. For now this is limited to the id field because of the possible complexity of fetching and filtering all the related data.

Protected Methods

Method Description
getExistingRelations ( mixed $entity ) : array Get existing relationship records.
getInverseRelations ( mixed $entity ) : array Get inverse relationship records. That is ones where the definition happened on the opposite record
getPlatformGroupConcat ( string $column, string $alias, Doctrine\DBAL\Query\QueryBuilder $query ) : string Get platform specific group_concat token for provided column

Method Details

getExistingRelations() protected method

Get existing relationship records.
protected getExistingRelations ( mixed $entity ) : array
$entity mixed
return array

getInverseRelations() protected method

Get inverse relationship records. That is ones where the definition happened on the opposite record
protected getInverseRelations ( mixed $entity ) : array
$entity mixed
return array

getName() public method

public getName ( )

getPlatformGroupConcat() protected method

Get platform specific group_concat token for provided column
protected getPlatformGroupConcat ( string $column, string $alias, Doctrine\DBAL\Query\QueryBuilder $query ) : string
$column string
$alias string
$query Doctrine\DBAL\Query\QueryBuilder
return string

hydrate() public method

public hydrate ( $data, $entity )

load() public method

IDs are returned comma-separated which the ->hydrate() method can then turn into pointers to the related entities.
public load ( Doctrine\DBAL\Query\QueryBuilder $query, Bolt\Storage\Mapping\ClassMetadata $metadata ) : void
$query Doctrine\DBAL\Query\QueryBuilder
$metadata Bolt\Storage\Mapping\ClassMetadata
return void

persist() public method

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

query() public method

For example the following queries: 'pages', {'relationkey'=>'1'} 'pages', {'relationkey'=>'1 || 2 || 3'}. Because the search is actually on the join table, we replace the expression to filter the join side rather than on the main side.
public query ( Bolt\Storage\Query\QueryInterface $query, Bolt\Storage\Mapping\ClassMetadata $metadata ) : void
$query Bolt\Storage\Query\QueryInterface
$metadata Bolt\Storage\Mapping\ClassMetadata
return void