PHP Класс Sokil\Mongo\Document

Автор: Dmytro Sokil ([email protected])
Наследование: extends Structure
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__call ( $name, $arguments )
__construct ( Collection $collection, array $data = null, array $options = [] )
__get ( $name )
__toString ( )
__unset ( $fieldName )
addRelation ( $relationName, Document $document )
addToSet ( $fieldName, $value )
addToSetEach ( $fieldName, array $values )
append ( type $selector, type $value ) : Structure If field not exist - set value.
attachBehavior ( string $name, string | array | Sokil\Mongo\Behavior $behavior ) : Document
attachBehaviors ( array $behaviors )
attachEvent ( string $event, callable | array | string $handler, $priority ) : Document Attach event handler
beforeConstruct ( ) Event handler, called before running constructor.
behaviors ( )
bitwiceAnd ( $field, $value )
bitwiceOr ( $field, $value )
bitwiceXor ( $field, $value )
clearBehaviors ( )
clearRevisions ( )
createReference ( ) : array Get reference to document
decrement ( $fieldName, $value = 1 )
defineId ( MongoId | string $id ) : Document Used to define id of stored document. This id must be already present in db
delete ( )
getCollection ( ) : Collection Get instance of collection
getId ( )
getOperator ( )
getOption ( $name, $default = null )
getOptions ( )
getReferencedDocument ( string $name ) : null | Document Get document by reference
getReferencedDocumentList ( string $name ) : null | Document Get document by reference
getRelated ( string $relationName ) : array | Document Get related documents
getRelationDefinition ( ) : array Relation definition through mapping is more prior to defined in class
getRevision ( $id )
getRevisionManager ( ) : Sokil\Mongo\RevisionManager
getRevisions ( $limit = null, $offset = null )
getRevisionsCount ( )
hasEvent ( string $event ) : boolean Check if event attached
hasOption ( $name )
increment ( $fieldName, $value = 1 )
isModificationOperatorDefined ( )
isSaveRequired ( )
isStored ( )
merge ( array $data ) : Document
pull ( integer | string | array | Expression | callable $expression, mixed | Expression | callable $value = null ) : Document Removes from an existing array all instances of a value or values that match a specified query
push ( string $fieldName, mixed $value ) : Document Push argument as single element to field value
pushEach ( string $fieldName, array $values ) : Document Push each element of argument's array as single element to field value
pushReference ( string $name, Document $document ) : Document Push reference to list
refresh ( ) Reload data from db and reset all unsaved data
removeRelation ( $relationName, Document $document = null )
reset ( ) : Document Reset all data passed to object in run-time, like events, behaviors, data modifications, etc. to the state just after open or save document
save ( $validate = true )
set ( string $fieldName, mixed $value ) : Document Update value in local cache and in DB
setGeometry ( string $field, GeoJson\Geometry\Geometry $geometry ) : Document Set geo data as GeoJson object
setGeometryCollection ( string $field, array $geometryCollection ) : Document Set collection of different geometries
setId ( MongoId | string $id ) : Document Used to define id of not stored document.
setLegacyPoint ( string $field, float $longitude, float $latitude ) : Document Set point as longitude and latitude in legacy format
setLineString ( string $field, array $pointArray ) : Document Set line string as array of points
setMultiLineString ( string $field, array $lineStringArray ) : Document Set multi line string as array of line strings
setMultiPoint ( string $field, array $pointArray ) : Document Set multi point as array of points
setMultyPolygon ( string $field, array $polygonsArray ) : Document Set multy polygon as array of polygons.
setPoint ( string $field, float $longitude, float $latitude ) : Document Set point as longitude and latitude
setPolygon ( string $field, array $lineRingsArray ) : Document Set polygon as array of line rings.
setReference ( $name, Document $document ) : Document Store DBRef to specified field
triggerEvent ( string $eventName, Event $event = null ) : Event Manually trigger defined events
unsetField ( string $fieldName ) : Document Remove field
validate ( ) : Document

Защищенные методы

Метод Описание
relations ( ) : array Override in child class to define relations

Приватные методы

Метод Описание
getRelationManager ( ) : Sokil\Mongo\Document\RelationManager
initDelegates ( ) Initialise relative classes

Описание методов

__call() публичный Метод

public __call ( $name, $arguments )

__construct() публичный Метод

public __construct ( Collection $collection, array $data = null, array $options = [] )
$collection Collection instance of Mongo collection
$data array mongo document
$options array options of object initialization

__get() публичный Метод

public __get ( $name )

__toString() публичный Метод

public __toString ( )

__unset() публичный Метод

public __unset ( $fieldName )

addRelation() публичный Метод

public addRelation ( $relationName, Document $document )
$document Document

addToSet() публичный Метод

public addToSet ( $fieldName, $value )

addToSetEach() публичный Метод

public addToSetEach ( $fieldName, array $values )
$values array

append() публичный Метод

If field exists and is not array - convert to array and append If field -s array - append
public append ( type $selector, type $value ) : Structure
$selector type
$value type
Результат Structure

attachBehavior() публичный Метод

public attachBehavior ( string $name, string | array | Sokil\Mongo\Behavior $behavior ) : Document
$name string unique name of attached behavior
$behavior string | array | Sokil\Mongo\Behavior Behavior instance or behavior definition
Результат Document

attachBehaviors() публичный Метод

public attachBehaviors ( array $behaviors )
$behaviors array

attachEvent() публичный Метод

Attach event handler
public attachEvent ( string $event, callable | array | string $handler, $priority ) : Document
$event string event name
$handler callable | array | string event handler
Результат Document

beforeConstruct() публичный Метод

May be overridden in child classes
public beforeConstruct ( )

behaviors() публичный Метод

public behaviors ( )

bitwiceAnd() публичный Метод

public bitwiceAnd ( $field, $value )

bitwiceOr() публичный Метод

public bitwiceOr ( $field, $value )

bitwiceXor() публичный Метод

public bitwiceXor ( $field, $value )

clearBehaviors() публичный Метод

public clearBehaviors ( )

clearRevisions() публичный Метод

Устаревший: since 1.13.0 use self::getRevisionManager()->clearRevisions()
public clearRevisions ( )

createReference() публичный Метод

Get reference to document
public createReference ( ) : array
Результат array

decrement() публичный Метод

public decrement ( $fieldName, $value = 1 )

defineId() публичный Метод

Used to define id of stored document. This id must be already present in db
public defineId ( MongoId | string $id ) : Document
$id MongoId | string id of document
Результат Document

delete() публичный Метод

public delete ( )

getCollection() публичный Метод

Get instance of collection
public getCollection ( ) : Collection
Результат Collection

getId() публичный Метод

public getId ( )

getOperator() публичный Метод

public getOperator ( )

getOption() публичный Метод

public getOption ( $name, $default = null )

getOptions() публичный Метод

public getOptions ( )

getReferencedDocument() публичный Метод

Get document by reference
public getReferencedDocument ( string $name ) : null | Document
$name string name of field where reference stored
Результат null | Document

getReferencedDocumentList() публичный Метод

Get document by reference
public getReferencedDocumentList ( string $name ) : null | Document
$name string name of field where reference stored
Результат null | Document

getRelated() публичный Метод

Get related documents
public getRelated ( string $relationName ) : array | Document
$relationName string
Результат array | Document related document or array of documents

getRelationDefinition() публичный Метод

Relation definition through mapping is more prior to defined in class
public getRelationDefinition ( ) : array
Результат array definition of relations

getRevision() публичный Метод

Устаревший: since 1.13.0 use self::getRevisionManager()->getRevision()
public getRevision ( $id )

getRevisionManager() публичный Метод

public getRevisionManager ( ) : Sokil\Mongo\RevisionManager
Результат Sokil\Mongo\RevisionManager

getRevisions() публичный Метод

Устаревший: since 1.13.0 use self::getRevisionManager()->getRevisions()
public getRevisions ( $limit = null, $offset = null )

getRevisionsCount() публичный Метод

Устаревший: since 1.13.0 use self::getRevisionManager()->getRevisionsCount()
public getRevisionsCount ( )

hasEvent() публичный Метод

Check if event attached
public hasEvent ( string $event ) : boolean
$event string event name
Результат boolean

hasOption() публичный Метод

public hasOption ( $name )

increment() публичный Метод

public increment ( $fieldName, $value = 1 )

isModificationOperatorDefined() публичный Метод

isSaveRequired() публичный Метод

public isSaveRequired ( )

isStored() публичный Метод

public isStored ( )

merge() публичный Метод

public merge ( array $data ) : Document
$data array
Результат Document

pull() публичный Метод

Removes from an existing array all instances of a value or values that match a specified query
public pull ( integer | string | array | Expression | callable $expression, mixed | Expression | callable $value = null ) : Document
$expression integer | string | array | Expression | callable
$value mixed | Expression | callable
Результат Document

push() публичный Метод

Push argument as single element to field value
public push ( string $fieldName, mixed $value ) : Document
$fieldName string
$value mixed
Результат Document

pushEach() публичный Метод

Push each element of argument's array as single element to field value
public pushEach ( string $fieldName, array $values ) : Document
$fieldName string
$values array
Результат Document

pushReference() публичный Метод

Push reference to list
public pushReference ( string $name, Document $document ) : Document
$name string
$document Document
Результат Document

refresh() публичный Метод

Reload data from db and reset all unsaved data
public refresh ( )

relations() защищенный Метод

Override in child class to define relations
protected relations ( ) : array
Результат array relation description

removeRelation() публичный Метод

public removeRelation ( $relationName, Document $document = null )
$document Document

reset() публичный Метод

Reset all data passed to object in run-time, like events, behaviors, data modifications, etc. to the state just after open or save document
public reset ( ) : Document
Результат Document

save() публичный Метод

public save ( $validate = true )

set() публичный Метод

Update value in local cache and in DB
public set ( string $fieldName, mixed $value ) : Document
$fieldName string point-delimited field name
$value mixed value to store
Результат Document

setGeometry() публичный Метод

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon. Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setGeometry ( string $field, GeoJson\Geometry\Geometry $geometry ) : Document
$field string
$geometry GeoJson\Geometry\Geometry
Результат Document

setGeometryCollection() публичный Метод

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setGeometryCollection ( string $field, array $geometryCollection ) : Document
$field string
$geometryCollection array
Результат Document

setId() публичный Метод

Used to define id of not stored document.
public setId ( MongoId | string $id ) : Document
$id MongoId | string id of document
Результат Document

setLegacyPoint() публичный Метод

May be used 2d index
public setLegacyPoint ( string $field, float $longitude, float $latitude ) : Document
$field string
$longitude float
$latitude float
Результат Document

setLineString() публичный Метод

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setLineString ( string $field, array $pointArray ) : Document
$field string
$pointArray array array of points
Результат Document

setMultiLineString() публичный Метод

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection. http://docs.mongodb.org/manual/core/2dsphere/#multilinestring
public setMultiLineString ( string $field, array $lineStringArray ) : Document
$field string
$lineStringArray array array of line strings
Результат Document

setMultiPoint() публичный Метод

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setMultiPoint ( string $field, array $pointArray ) : Document
$field string
$pointArray array array of point arrays
Результат Document

setMultyPolygon() публичный Метод

Polygon is array of line rings. Line ring is closed line string (first and last point same). Line string is array of points. Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setMultyPolygon ( string $field, array $polygonsArray ) : Document
$field string
$polygonsArray array array of polygons
Результат Document

setPoint() публичный Метод

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setPoint ( string $field, float $longitude, float $latitude ) : Document
$field string
$longitude float
$latitude float
Результат Document

setPolygon() публичный Метод

Line ring is closed line string (first and last point same). Line string is array of points. Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setPolygon ( string $field, array $lineRingsArray ) : Document
$field string
$lineRingsArray array array of line rings
Результат Document

setReference() публичный Метод

Store DBRef to specified field
public setReference ( $name, Document $document ) : Document
$name
$document Document
Результат Document

triggerEvent() публичный Метод

Manually trigger defined events
public triggerEvent ( string $eventName, Event $event = null ) : Event
$eventName string event name
$event Event
Результат Event

unsetField() публичный Метод

Remove field
public unsetField ( string $fieldName ) : Document
$fieldName string field name
Результат Document

validate() публичный Метод

public validate ( ) : Document
Результат Document