PHP Class Doctrine\ODM\MongoDB\DocumentRepository

This class is designed for inheritance and users can subclass this class to write their own repositories with business-specific methods to locate documents.
Since: 1.0
Author: Jonathan H. Wage ([email protected])
Author: Roman Borschel ([email protected])
Inheritance: implements Doctrine\Common\Persistence\ObjectRepository, implements Doctrine\Common\Collections\Selectable
ファイルを表示 Open project: doctrine/mongodb-odm Class Usage Examples

Protected Properties

Property Type Description
$class Doctrine\ODM\MongoDB\Mapping\ClassMetadata
$dm DocumentManager
$documentName string
$uow UnitOfWork

Public Methods

Method Description
__call ( string $method, array $arguments ) : array | object Adds support for magic finders.
__construct ( DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata ) Initializes this instance with the specified document manager, unit of work and class metadata.
clear ( ) Clears the repository, causing all managed documents to become detached.
createAggregationBuilder ( ) : Builder Creates a new Aggregation\Builder instance that is prepopulated for this document name.
createQueryBuilder ( ) : Builder Creates a new Query\Builder instance that is preconfigured for this document name.
find ( mixed $id, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object | null Finds a document matching the specified identifier. Optionally a lock mode and expected version may be specified.
findAll ( ) : array Finds all documents in the repository.
findBy ( array $criteria, array $sort = null, integer | null $limit = null, integer | null $skip = null ) : array Finds documents by a set of criteria.
findOneBy ( array $criteria ) : object Finds a single document by a set of criteria.
getClassMetadata ( ) : ClassMetadata
getClassName ( ) : string
getDocumentManager ( ) : DocumentManager
getDocumentName ( ) : string
matching ( Doctrine\Common\Collections\Criteria $criteria ) : Doctrine\Common\Collections\Collection Selects all elements from a selectable that match the expression and returns a new collection containing these elements.

Protected Methods

Method Description
getDocumentPersister ( )

Method Details

__call() public method

Adds support for magic finders.
public __call ( string $method, array $arguments ) : array | object
$method string
$arguments array
return array | object The found document/documents.

__construct() public method

Initializes this instance with the specified document manager, unit of work and class metadata.
public __construct ( DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata )
$dm DocumentManager The DocumentManager to use.
$uow UnitOfWork The UnitOfWork to use.
$classMetadata Doctrine\ODM\MongoDB\Mapping\ClassMetadata The class metadata.

clear() public method

Clears the repository, causing all managed documents to become detached.
public clear ( )

createAggregationBuilder() public method

Creates a new Aggregation\Builder instance that is prepopulated for this document name.
public createAggregationBuilder ( ) : Builder
return Doctrine\ODM\MongoDB\Aggregation\Builder

createQueryBuilder() public method

Creates a new Query\Builder instance that is preconfigured for this document name.
public createQueryBuilder ( ) : Builder
return Doctrine\ODM\MongoDB\Query\Builder $qb

find() public method

Finds a document matching the specified identifier. Optionally a lock mode and expected version may be specified.
public find ( mixed $id, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object | null
$id mixed Identifier.
$lockMode integer Optional. Lock mode; one of the LockMode constants.
$lockVersion integer Optional. Expected version.
return object | null The document, if found, otherwise null.

findAll() public method

Finds all documents in the repository.
public findAll ( ) : array
return array

findBy() public method

Finds documents by a set of criteria.
public findBy ( array $criteria, array $sort = null, integer | null $limit = null, integer | null $skip = null ) : array
$criteria array Query criteria
$sort array Sort array for Cursor::sort()
$limit integer | null Limit for Cursor::limit()
$skip integer | null Skip for Cursor::skip()
return array

findOneBy() public method

Finds a single document by a set of criteria.
public findOneBy ( array $criteria ) : object
$criteria array
return object

getClassMetadata() public method

public getClassMetadata ( ) : ClassMetadata
return Doctrine\ODM\MongoDB\Mapping\ClassMetadata

getClassName() public method

public getClassName ( ) : string
return string

getDocumentManager() public method

public getDocumentManager ( ) : DocumentManager
return DocumentManager

getDocumentName() public method

public getDocumentName ( ) : string
return string

getDocumentPersister() protected method

protected getDocumentPersister ( )

matching() public method

Selects all elements from a selectable that match the expression and returns a new collection containing these elements.
See also: Selectable::matching()
public matching ( Doctrine\Common\Collections\Criteria $criteria ) : Doctrine\Common\Collections\Collection
$criteria Doctrine\Common\Collections\Criteria
return Doctrine\Common\Collections\Collection

Property Details

$class protected_oe property

protected ClassMetadata,Doctrine\ODM\MongoDB\Mapping $class
return Doctrine\ODM\MongoDB\Mapping\ClassMetadata

$dm protected_oe property

protected DocumentManager,Doctrine\ODM\MongoDB $dm
return DocumentManager

$documentName protected_oe property

protected string $documentName
return string

$uow protected_oe property

protected UnitOfWork,Doctrine\ODM\MongoDB $uow
return UnitOfWork