class DefaultGridFSRepository extends DocumentRepository implements GridFSRepository (View source)

Properties

protected string $documentName from DocumentRepository
protected DocumentManager $dm from DocumentRepository
protected UnitOfWork $uow from DocumentRepository
protected ClassMetadata $class from DocumentRepository

Methods

__construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata)

Initializes this instance with the specified document manager, unit of work and class metadata.

createQueryBuilder()

Creates a new Query\Builder instance that is preconfigured for this document name.

createAggregationBuilder()

Creates a new Aggregation\Builder instance that is prepopulated for this document name.

clear()

Clears the repository, causing all managed documents to become detached.

object|null
find(mixed $id, int $lockMode = LockMode::NONE, int $lockVersion = null)

Finds a document matching the specified identifier. Optionally a lock mode and expected version may be specified.

array
findAll()

Finds all documents in the repository.

array
findBy(array $criteria, array|null $sort = null, int|null $limit = null, int|null $skip = null)

Finds documents by a set of criteria.

object
findOneBy(array $criteria)

Finds a single document by a set of criteria.

string
getDocumentName()

No description

string
getClassName()

No description

Collection
matching(Criteria $criteria)

Selects all elements from a selectable that match the expression and returns a new collection containing these elements.

getDocumentPersister()

No description

resource
openDownloadStream(mixed $id)

No description

downloadToStream(mixed $id, resource $destination)

No description

resource
openUploadStream(string $filename, UploadOptions|null $uploadOptions = null)

No description

object
uploadFromStream(string $filename, $source, UploadOptions|null $uploadOptions = null)

No description

object
uploadFromFile(string $source, string|null $filename = null, UploadOptions|null $uploadOptions = null)

Writes the contents of a file to a GridFS file.

Details

__construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $classMetadata)

Initializes this instance with the specified document manager, unit of work and class metadata.

Parameters

DocumentManager $dm The DocumentManager to use.
UnitOfWork $uow The UnitOfWork to use.
ClassMetadata $classMetadata The class metadata.

Builder createQueryBuilder()

Creates a new Query\Builder instance that is preconfigured for this document name.

Return Value

Builder $qb

Builder createAggregationBuilder()

Creates a new Aggregation\Builder instance that is prepopulated for this document name.

Return Value

Builder

clear()

Clears the repository, causing all managed documents to become detached.

object|null find(mixed $id, int $lockMode = LockMode::NONE, int $lockVersion = null)

Finds a document matching the specified identifier. Optionally a lock mode and expected version may be specified.

Parameters

mixed $id Identifier.
int $lockMode Optional. Lock mode; one of the LockMode constants.
int $lockVersion Optional. Expected version.

Return Value

object|null The document, if found, otherwise null.

Exceptions

MappingException
LockException

array findAll()

Finds all documents in the repository.

Return Value

array

array findBy(array $criteria, array|null $sort = null, int|null $limit = null, int|null $skip = null)

Finds documents by a set of criteria.

Parameters

array $criteria Query criteria
array|null $sort Sort array for Cursor::sort()
int|null $limit Limit for Cursor::limit()
int|null $skip Skip for Cursor::skip()

Return Value

array

object findOneBy(array $criteria)

Finds a single document by a set of criteria.

Parameters

array $criteria

Return Value

object

string getDocumentName()

Return Value

string

DocumentManager getDocumentManager()

Return Value

DocumentManager

ClassMetadata getClassMetadata()

Return Value

ClassMetadata

string getClassName()

Return Value

string

Collection matching(Criteria $criteria)

Selects all elements from a selectable that match the expression and returns a new collection containing these elements.

Parameters

Criteria $criteria

Return Value

Collection

See also

Selectable::matching()

protected getDocumentPersister()

resource openDownloadStream(mixed $id)

Parameters

mixed $id File ID

Return Value

resource

See also

Bucket::openDownloadStream()

downloadToStream(mixed $id, resource $destination)

Parameters

mixed $id File ID
resource $destination Writable Stream

See also

Bucket::downloadToStream

resource openUploadStream(string $filename, UploadOptions|null $uploadOptions = null)

Parameters

string $filename
UploadOptions|null $uploadOptions

Return Value

resource

See also

Bucket::openUploadStream

object uploadFromStream(string $filename, $source, UploadOptions|null $uploadOptions = null)

Parameters

string $filename
$source
UploadOptions|null $uploadOptions

Return Value

object The newly created GridFS file

See also

Bucket::uploadFromStream

object uploadFromFile(string $source, string|null $filename = null, UploadOptions|null $uploadOptions = null)

Writes the contents of a file to a GridFS file.

Parameters

string $source
string|null $filename
UploadOptions|null $uploadOptions

Return Value

object The newly created GridFS file