PHP Class FactoryGirl\Provider\Doctrine\ORM\Repository

Inheritance: extends Doctrine\ORM\EntityRepository
Show file Open project: breerly/factory-girl-php Class Usage Examples

Public Methods

Method Description
getEntityName ( ) : string
getReference ( mixed $identifier ) : object Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
transaction ( $transaction ) : mixed Perform a callback function within a transaction. If an exception occurs within the function, it's catched, the transaction is rolled back and the exception rethrown.
transactionWithTableLock ( integer $lockMode, callback $transaction ) : mixed Attempt to acquire a table level lock in MySQL for the duration of the given transaction. IS NOT IN ANY WAY GUARANTEED TO WORK.
useWithLock ( integer $id, integer $lockMode, $callback ) : mixed Acquires a lock to an entity, provides the entity to a callback function and relinquishes the lock by flushing the entity manager immediately after.
useWithPessimisticVersionLock ( integer $id, mixed $lockVersion, $callback ) : mixed Acquires an optimistic lock within a pessimistic lock transaction. For use in fail-fast scenarios; guaranteed to throw an exception on concurrent modification attempts. The one to first acquire the write lock will update the version field, leading subsequent acquisitions of the optimistic lock to fail.
useWithPessimisticWriteLock ( integer $id, $callback ) : mixed Calls useWithLock() with a pessimistic write lock mode

Protected Methods

Method Description
getBaseQueryBuilder ( ) : QueryBuilder Create a query builder. Override this in a child class to create a builder of the appropriate type.
getQueryResult ( Doctrine\ORM\QueryBuilder $builder ) : mixed
getSingleQueryResult ( Doctrine\ORM\QueryBuilder $builder, callback(Exception) $fallback = null ) : object | null
getSingleScalarQueryResult ( Doctrine\ORM\QueryBuilder $builder, callback(Exception) $fallback = null ) : object | null
withQueryBuilder ( $do ) : QueryBuilder Create a query builder, perform the given operation on it and return the query builder. The operation callback receives the query builder and its associated expression builder as arguments.

Private Methods

Method Description
attemptQuery ( callback $do, callback $fallback = null ) : mixed Guards against NoResultException and NonUniqueResultException within a callback. Uses a fallback callback in case an exception does occur.
getTableLock ( ) : TableLock

Method Details

getBaseQueryBuilder() protected method

Create a query builder. Override this in a child class to create a builder of the appropriate type.
protected getBaseQueryBuilder ( ) : QueryBuilder
return QueryBuilder

getEntityName() public method

public getEntityName ( ) : string
return string

getQueryResult() protected method

protected getQueryResult ( Doctrine\ORM\QueryBuilder $builder ) : mixed
$builder Doctrine\ORM\QueryBuilder
return mixed result

getReference() public method

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
public getReference ( mixed $identifier ) : object
$identifier mixed The entity identifier.
return object The entity reference.

getSingleQueryResult() protected method

protected getSingleQueryResult ( Doctrine\ORM\QueryBuilder $builder, callback(Exception) $fallback = null ) : object | null
$builder Doctrine\ORM\QueryBuilder
$fallback callback(Exception)
return object | null | null result or return value from fallback

getSingleScalarQueryResult() protected method

protected getSingleScalarQueryResult ( Doctrine\ORM\QueryBuilder $builder, callback(Exception) $fallback = null ) : object | null
$builder Doctrine\ORM\QueryBuilder
$fallback callback(Exception)
return object | null | null result or return value from fallback

transaction() public method

Perform a callback function within a transaction. If an exception occurs within the function, it's catched, the transaction is rolled back and the exception rethrown.
public transaction ( $transaction ) : mixed
return mixed the callback return value

transactionWithTableLock() public method

Attempt to acquire a table level lock in MySQL for the duration of the given transaction. IS NOT IN ANY WAY GUARANTEED TO WORK.
See also: TableLock
public transactionWithTableLock ( integer $lockMode, callback $transaction ) : mixed
$lockMode integer a TableLockMode constant
$transaction callback
return mixed

useWithLock() public method

Acquires a lock to an entity, provides the entity to a callback function and relinquishes the lock by flushing the entity manager immediately after.
public useWithLock ( integer $id, integer $lockMode, $callback ) : mixed
$id integer
$lockMode integer
return mixed callback return type

useWithPessimisticVersionLock() public method

FIXME: Only works on entities implementing VersionLockable and does not work in conjunction with the Doctrine @Version column.
public useWithPessimisticVersionLock ( integer $id, mixed $lockVersion, $callback ) : mixed
$id integer
$lockVersion mixed
return mixed callback return type

useWithPessimisticWriteLock() public method

Calls useWithLock() with a pessimistic write lock mode
public useWithPessimisticWriteLock ( integer $id, $callback ) : mixed
$id integer
return mixed callback return type

withQueryBuilder() protected method

Create a query builder, perform the given operation on it and return the query builder. The operation callback receives the query builder and its associated expression builder as arguments.
protected withQueryBuilder ( $do ) : QueryBuilder
return QueryBuilder