class LoggableCursor extends Cursor implements Loggable (View source)

Wrapper for the MongoCursor class with logging functionality.

Properties

protected Collection $collection The Collection instance used for recreating this cursor. from Cursor
protected MongoCursor $mongoCursor The MongoCursor instance being wrapped. from Cursor
protected integer $numRetries Number of times to retry queries. from Cursor
protected boolean $useIdentifierKeys Whether to use the document's "_id" value as its iteration key. from Cursor
protected $query from Cursor
protected $fields from Cursor
protected $hint from Cursor
protected $immortal from Cursor
protected $options from Cursor
protected $batchSize from Cursor
protected $limit from Cursor
protected $maxTimeMS from Cursor
protected $readPreference from Cursor
protected $readPreferenceTags from Cursor
protected $skip from Cursor
protected $slaveOkay from Cursor
protected $snapshot from Cursor
protected $sort from Cursor
protected $tailable from Cursor
protected $timeout from Cursor
protected callable $loggerCallable The logger callable.

Methods

__construct(Collection $collection, MongoCursor $mongoCursor, array $query, array $fields, integer $numRetries, callable $loggerCallable)

Constructor.

$this
addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

from Cursor
$this
batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

from Cursor
integer
count(boolean $foundOnly = false)

Wrapper method for MongoCursor::count().

from Cursor
array|null
current()

Wrapper method for MongoCursor::current().

from Cursor
boolean
dead()

Wrapper method for MongoCursor::dead().

from Cursor
array
explain()

Wrapper method for MongoCursor::explain().

from Cursor
$this
fields(array $f)

Wrapper method for MongoCursor::fields().

from Cursor
getCollection()

Return the collection for this cursor.

from Cursor
getConnection() deprecated

Return the connection for this cursor.

from Cursor
array
getFields()

Return the selected fields (projection).

from Cursor
MongoCursor
getMongoCursor()

Returns the MongoCursor instance being wrapped.

from Cursor
array|null
getNext()

Wrapper method for MongoCursor::getNext().

from Cursor
array
getQuery()

Return the query criteria.

from Cursor
array
getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

from Cursor
$this
setReadPreference(string $readPreference, array $tags = null)

Set the read preference.

from Cursor
array|object|null
getSingleResult()

Reset the cursor and return its first result.

from Cursor
boolean
getUseIdentifierKeys()

Return whether the document's "_id" value is used as its iteration key.

from Cursor
$this
setUseIdentifierKeys(boolean $useIdentifierKeys)

Set whether to use the document's "_id" value as its iteration key.

from Cursor
boolean
hasNext()

Wrapper method for MongoCursor::hasNext().

from Cursor
$this
hint(array|string $keyPattern)

No description

$this
immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

from Cursor
array
info()

Wrapper method for MongoCursor::info().

from Cursor
mixed
key()

Wrapper method for MongoCursor::key().

from Cursor
$this
limit(integer $num)

No description

$this
maxTimeMS(integer $ms)

No description

next()

Wrapper method for MongoCursor::next().

from Cursor
recreate()

Recreates the internal MongoCursor.

from Cursor
reset()

Wrapper method for MongoCursor::reset().

from Cursor
rewind()

Wrapper method for MongoCursor::rewind().

from Cursor
setMongoCursorSlaveOkay(boolean $ok)

Set whether secondary read queries are allowed for this cursor.

from Cursor
$this
skip(integer $num)

No description

$this
slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

from Cursor
$this
snapshot()

No description

$this
sort(array $fields)

No description

$this
tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

from Cursor
$this
timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

from Cursor
array
toArray(boolean $useIdentifierKeys = null)

Return the cursor's results as an array.

from Cursor
boolean
valid()

Wrapper method for MongoCursor::valid().

from Cursor
mixed
retry(Closure $retry, boolean $recreate = false)

Conditionally retry a closure if it yields an exception.

from Cursor
log(array $data)

Log something using the configured logger callable.

callable
getLoggerCallable()

Get the logger callable.

Details

__construct(Collection $collection, MongoCursor $mongoCursor, array $query, array $fields, integer $numRetries, callable $loggerCallable)

Constructor.

Parameters

Collection $collection Collection used to create this Cursor
MongoCursor $mongoCursor MongoCursor instance being wrapped
array $query Query criteria
array $fields Selected fields (projection)
integer $numRetries Number of times to retry queries
callable $loggerCallable Logger callable

$this addOption(string $key, mixed $value)

Wrapper method for MongoCursor::addOption().

Parameters

string $key
mixed $value

Return Value

$this

See also

http://php.net/manual/en/mongocursor.addoption.php

$this batchSize(integer $num)

Wrapper method for MongoCursor::batchSize().

Parameters

integer $num

Return Value

$this

See also

http://php.net/manual/en/mongocursor.batchsize.php

integer count(boolean $foundOnly = false)

Wrapper method for MongoCursor::count().

Parameters

boolean $foundOnly

Return Value

integer

See also

http://php.net/manual/en/countable.count.php
http://php.net/manual/en/mongocursor.count.php

array|null current()

Wrapper method for MongoCursor::current().

boolean dead()

Wrapper method for MongoCursor::dead().

Return Value

boolean

See also

http://php.net/manual/en/mongocursor.dead.php

array explain()

Wrapper method for MongoCursor::explain().

$this fields(array $f)

Wrapper method for MongoCursor::fields().

Parameters

array $f Fields to return (or not return).

Return Value

$this

See also

http://php.net/manual/en/mongocursor.fields.php

Collection getCollection()

Return the collection for this cursor.

Return Value

Collection

Connection getConnection() deprecated

deprecated 1.1 Will be removed for 2.0

Return the connection for this cursor.

Return Value

Connection

array getFields()

Return the selected fields (projection).

Return Value

array

MongoCursor getMongoCursor()

Returns the MongoCursor instance being wrapped.

Return Value

MongoCursor

array|null getNext()

Wrapper method for MongoCursor::getNext().

Return Value

array|null

See also

http://php.net/manual/en/mongocursor.getnext.php

array getQuery()

Return the query criteria.

Return Value

array

array getReadPreference()

Wrapper method for MongoCursor::getReadPreference().

$this setReadPreference(string $readPreference, array $tags = null)

Set the read preference.

Parameters

string $readPreference
array $tags

Return Value

$this

See also

http://php.net/manual/en/mongocursor.setreadpreference.php

array|object|null getSingleResult()

Reset the cursor and return its first result.

The cursor will be reset both before and after the single result is fetched. The original cursor limit (if any) will remain in place.

Return Value

array|object|null

See also

Iterator::getSingleResult

boolean getUseIdentifierKeys()

Return whether the document's "_id" value is used as its iteration key.

Return Value

boolean

$this setUseIdentifierKeys(boolean $useIdentifierKeys)

Set whether to use the document's "_id" value as its iteration key.

Parameters

boolean $useIdentifierKeys

Return Value

$this

boolean hasNext()

Wrapper method for MongoCursor::hasNext().

Return Value

boolean

See also

http://php.net/manual/en/mongocursor.hasnext.php

$this hint(array|string $keyPattern)

Parameters

array|string $keyPattern

Return Value

$this

See also

Cursor::hint

$this immortal(boolean $liveForever = true)

Wrapper method for MongoCursor::immortal().

Parameters

boolean $liveForever

Return Value

$this

See also

http://php.net/manual/en/mongocursor.immortal.php

array info()

Wrapper method for MongoCursor::info().

Return Value

array

See also

http://php.net/manual/en/mongocursor.info.php

mixed key()

Wrapper method for MongoCursor::key().

$this limit(integer $num)

Parameters

integer $num

Return Value

$this

See also

Cursor::limit

$this maxTimeMS(integer $ms)

Parameters

integer $ms

Return Value

$this

See also

Cursor::maxTimeMS

recreate()

Recreates the internal MongoCursor.

reset()

rewind()

setMongoCursorSlaveOkay(boolean $ok)

Set whether secondary read queries are allowed for this cursor.

This method wraps setSlaveOkay() for driver versions before 1.3.0. For newer drivers, this method either wraps setReadPreference() method and specifies SECONDARY_PREFERRED or does nothing, depending on whether setReadPreference() exists.

Parameters

boolean $ok

$this skip(integer $num)

Parameters

integer $num

Return Value

$this

See also

Cursor::skip

$this slaveOkay(boolean $ok = true)

Wrapper method for MongoCursor::slaveOkay().

Parameters

boolean $ok

Return Value

$this

See also

http://php.net/manual/en/mongocursor.slaveokay.php

$this snapshot()

Return Value

$this

See also

Cursor::snapshot

$this sort(array $fields)

Parameters

array $fields

Return Value

$this

See also

Cursor::sort

$this tailable(boolean $tail = true)

Wrapper method for MongoCursor::tailable().

Parameters

boolean $tail

Return Value

$this

See also

http://php.net/manual/en/mongocursor.tailable.php

$this timeout(integer $ms)

Wrapper method for MongoCursor::timeout().

Parameters

integer $ms

Return Value

$this

See also

http://php.net/manual/en/mongocursor.timeout.php

array toArray(boolean $useIdentifierKeys = null)

Return the cursor's results as an array.

Parameters

boolean $useIdentifierKeys Deprecated since 1.2; will be removed in 2.0

Return Value

array

See also

Iterator::toArray

boolean valid()

Wrapper method for MongoCursor::valid().

protected mixed retry(Closure $retry, boolean $recreate = false)

Conditionally retry a closure if it yields an exception.

If the closure does not return successfully within the configured number of retries, its first exception will be thrown.

The $recreate parameter may be used to recreate the MongoCursor between retry attempts.

Parameters

Closure $retry
boolean $recreate

Return Value

mixed

log(array $data)

Log something using the configured logger callable.

Parameters

array $data

See also

Loggable::log

callable getLoggerCallable()

Get the logger callable.

Return Value

callable