PHP Class Bolt\Storage\Repository

Inheritance: implements Doctrine\Common\Persistence\ObjectRepository
Datei anzeigen Open project: bolt/bolt Class Usage Examples

Public Properties

Property Type Description
$_class Bolt\Storage\Mapping\ClassMetadata
$builder Bolt\Storage\Entity\Builder
$em EntityManager
$entityName string

Public Methods

Method Description
__construct ( EntityManager $em, Bolt\Storage\Mapping\ClassMetadata $classMetadata ) Initializes a new Repository.
create ( array $params = [], Bolt\Storage\Mapping\ClassMetadata $metadata = null ) : Bolt\Storage\Entity\Entity Creates a new empty entity and passes the supplied data to the constructor.
createQueryBuilder ( string $alias = null ) : Doctrine\DBAL\Query\QueryBuilder Creates a new QueryBuilder instance that is prepopulated for this entity name.
delete ( object $entity ) : boolean Deletes a single object.
event ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface Shortcut method to fetch the Event Dispatcher.
find ( $id )
findAll ( )
findBy ( array $criteria, array $orderBy = null, $limit = null, $offset = null )
findOneBy ( array $criteria, array $orderBy = null ) : object Finds a single object by a set of criteria.
findOneWith ( Doctrine\DBAL\Query\QueryBuilder $query ) : Bolt\Storage\Entity\Entity | false Method to hydrate and return a single QueryBuilder result.
findWith ( Doctrine\DBAL\Query\QueryBuilder $query ) : array Method to hydrate and return a QueryBuilder query.
getAlias ( ) : string
getClassMetadata ( ) : Bolt\Storage\Mapping\ClassMetadata Getter for class metadata.
getClassName ( ) : string
getEntityBuilder ( ) : Builder
getEntityManager ( ) : EntityManager
getEntityName ( ) : string
getFieldManager ( ) : FieldManager Fetches FieldManager instance from the EntityManager.
getTableName ( ) : string
insert ( object $entity ) : boolean Saves a new object into the database.
queryWith ( Bolt\Storage\Query\QueryInterface $query ) : array Method to execute query from a Bolt QueryInterface object The query is passed to the pre-load handlers then built into a QueryBuilder instance that can be executed.
save ( object $entity, boolean $silent = null ) : boolean Saves a single object.
update ( object $entity, string[] $exclusions = [] ) : boolean Updates an object into the database.

Protected Methods

Method Description
findWithCriteria ( array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null ) : Doctrine\DBAL\Query\QueryBuilder Internal method to build a basic select, returns QB object.
getLoadQuery ( ) : Doctrine\DBAL\Query\QueryBuilder Internal method to initialise and return a QueryBuilder instance.
hydrate ( array $data, Doctrine\DBAL\Query\QueryBuilder $qb ) : mixed Internal method to hydrate an Entity Object from fetched data.
hydrateAll ( array $data, Doctrine\DBAL\Query\QueryBuilder $qb ) : mixed Internal method to hydrate an array of Entity Objects from fetched data.
load ( Doctrine\DBAL\Query\QueryBuilder $query ) Internal method to run load method on each field for the managed entity.
persist ( Bolt\Storage\QuerySet $queries, Bolt\Storage\Entity\Entity $entity, array $exclusions = [] ) Internal method to run persist method on each field for the managed entity.
query ( Bolt\Storage\Query\QueryInterface $query ) Internal method to run query method on each field for the managed entity.
refresh ( $entity ) Internal method to refresh (re-hydrate an entity) using the field setters.

Method Details

__construct() public method

Initializes a new Repository.
public __construct ( EntityManager $em, Bolt\Storage\Mapping\ClassMetadata $classMetadata )
$em EntityManager The EntityManager to use.
$classMetadata Bolt\Storage\Mapping\ClassMetadata The class descriptor.

create() public method

Creates a new empty entity and passes the supplied data to the constructor.
public create ( array $params = [], Bolt\Storage\Mapping\ClassMetadata $metadata = null ) : Bolt\Storage\Entity\Entity
$params array
$metadata Bolt\Storage\Mapping\ClassMetadata
return Bolt\Storage\Entity\Entity

createQueryBuilder() public method

Creates a new QueryBuilder instance that is prepopulated for this entity name.
public createQueryBuilder ( string $alias = null ) : Doctrine\DBAL\Query\QueryBuilder
$alias string
return Doctrine\DBAL\Query\QueryBuilder

delete() public method

Deletes a single object.
public delete ( object $entity ) : boolean
$entity object The entity to delete.
return boolean

event() public method

Shortcut method to fetch the Event Dispatcher.
public event ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
return Symfony\Component\EventDispatcher\EventDispatcherInterface

find() public method

public find ( $id )

findAll() public method

public findAll ( )

findBy() public method

public findBy ( array $criteria, array $orderBy = null, $limit = null, $offset = null )
$criteria array
$orderBy array

findOneBy() public method

Finds a single object by a set of criteria.
public findOneBy ( array $criteria, array $orderBy = null ) : object
$criteria array The criteria.
$orderBy array
return object The object.

findOneWith() public method

Method to hydrate and return a single QueryBuilder result.
public findOneWith ( Doctrine\DBAL\Query\QueryBuilder $query ) : Bolt\Storage\Entity\Entity | false
$query Doctrine\DBAL\Query\QueryBuilder
return Bolt\Storage\Entity\Entity | false | false

findWith() public method

Method to hydrate and return a QueryBuilder query.
public findWith ( Doctrine\DBAL\Query\QueryBuilder $query ) : array
$query Doctrine\DBAL\Query\QueryBuilder
return array Entity

findWithCriteria() protected method

Internal method to build a basic select, returns QB object.
protected findWithCriteria ( array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null ) : Doctrine\DBAL\Query\QueryBuilder
$criteria array
$orderBy array
$limit integer
$offset integer
return Doctrine\DBAL\Query\QueryBuilder

getAlias() public method

public getAlias ( ) : string
return string

getClassMetadata() public method

Getter for class metadata.
public getClassMetadata ( ) : Bolt\Storage\Mapping\ClassMetadata
return Bolt\Storage\Mapping\ClassMetadata

getClassName() public method

public getClassName ( ) : string
return string

getEntityBuilder() public method

public getEntityBuilder ( ) : Builder
return Bolt\Storage\Entity\Builder $builder

getEntityManager() public method

public getEntityManager ( ) : EntityManager
return EntityManager

getEntityName() public method

public getEntityName ( ) : string
return string

getFieldManager() public method

Fetches FieldManager instance from the EntityManager.
public getFieldManager ( ) : FieldManager
return FieldManager

getLoadQuery() protected method

Note that the metadata fields will be passed the instance to modify where appropriate.
protected getLoadQuery ( ) : Doctrine\DBAL\Query\QueryBuilder
return Doctrine\DBAL\Query\QueryBuilder

getTableName() public method

public getTableName ( ) : string
return string

hydrate() protected method

Internal method to hydrate an Entity Object from fetched data.
protected hydrate ( array $data, Doctrine\DBAL\Query\QueryBuilder $qb ) : mixed
$data array
$qb Doctrine\DBAL\Query\QueryBuilder
return mixed

hydrateAll() protected method

Internal method to hydrate an array of Entity Objects from fetched data.
protected hydrateAll ( array $data, Doctrine\DBAL\Query\QueryBuilder $qb ) : mixed
$data array
$qb Doctrine\DBAL\Query\QueryBuilder
return mixed

insert() public method

Saves a new object into the database.
public insert ( object $entity ) : boolean
$entity object The entity to insert.
return boolean

load() protected method

Takes a QueryBuilder instance as input
protected load ( Doctrine\DBAL\Query\QueryBuilder $query )
$query Doctrine\DBAL\Query\QueryBuilder

persist() protected method

Takes a QuerySet instance as input
protected persist ( Bolt\Storage\QuerySet $queries, Bolt\Storage\Entity\Entity $entity, array $exclusions = [] )
$queries Bolt\Storage\QuerySet
$entity Bolt\Storage\Entity\Entity
$exclusions array

query() protected method

Takes a QueryInterface instance as input
protected query ( Bolt\Storage\Query\QueryInterface $query )
$query Bolt\Storage\Query\QueryInterface

queryWith() public method

Method to execute query from a Bolt QueryInterface object The query is passed to the pre-load handlers then built into a QueryBuilder instance that can be executed.
public queryWith ( Bolt\Storage\Query\QueryInterface $query ) : array
$query Bolt\Storage\Query\QueryInterface [description]
return array Entity | false

refresh() protected method

Internal method to refresh (re-hydrate an entity) using the field setters.
protected refresh ( $entity )
$entity

save() public method

Saves a single object.
public save ( object $entity, boolean $silent = null ) : boolean
$entity object The entity to save.
$silent boolean Suppress events
return boolean

update() public method

Updates an object into the database.
public update ( object $entity, string[] $exclusions = [] ) : boolean
$entity object The entity to update.
$exclusions string[] Ignore updates to these fields
return boolean

Property Details

$_class public_oe property

public ClassMetadata,Bolt\Storage\Mapping $_class
return Bolt\Storage\Mapping\ClassMetadata

$builder public_oe property

public Builder,Bolt\Storage\Entity $builder
return Bolt\Storage\Entity\Builder

$em public_oe property

public EntityManager,Bolt\Storage $em
return EntityManager

$entityName public_oe property

public string $entityName
return string